Skip to content

Commit

Permalink
Fix data source slug update (#204)
Browse files Browse the repository at this point in the history
When updating the new sanitized slug in form state it was compared with
the unsanitized version of it in the local state of SlugInput component.
This led to cases when the sanitized and unsanitized version being same,
the changed slug was not updated in form state leading to it not being
saved when 'Save' button on form was clicked. Comparing the local
sanitized version with slug in the form state fixes it.
  • Loading branch information
shekharnwagh authored Nov 19, 2024
1 parent d71d03e commit c7917e9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/data-sources/components/SlugInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const SlugInput: React.FC< SlugInputProps > = ( { slug, onChange, uuid }
const debouncedCheckSlugConflict = useDebounce( checkSlugConflict, 500 );
const onSlugUpdate = () => {
const sanitizedSlug = slugify( newSlug ?? '' );
if ( sanitizedSlug !== newSlug ) {
if ( sanitizedSlug !== slug ) {
setNewSlug( sanitizedSlug );
onChange( sanitizedSlug );
void debouncedCheckSlugConflict( sanitizedSlug, uuid ?? '' );
Expand Down

0 comments on commit c7917e9

Please sign in to comment.