#842 - Allow the slug to be set to an empty value

This commit is contained in:
Elio Struyf
2024-09-06 14:12:12 +02:00
parent d8e3338abe
commit e95e9a8fc7
6 changed files with 16 additions and 8 deletions
@@ -46,7 +46,7 @@ export const SlugField: React.FunctionComponent<ISlugFieldProps> = ({
if (text !== value) {
setText(value);
}
}, [value]);
}, [text, value]);
useEffect(() => {
if (titleValue) {
@@ -54,7 +54,7 @@ export const SlugField: React.FunctionComponent<ISlugFieldProps> = ({
title: titleValue,
slugTemplate
}).then((slug) => {
if (slug.slugWithPrefixAndSuffix) {
if (typeof slug.slugWithPrefixAndSuffix === "string") {
setSlug(slug.slugWithPrefixAndSuffix);
}
}).catch((_) => {
@@ -131,6 +131,8 @@ export const WrapperField: React.FunctionComponent<IWrapperFieldProps> = ({
if (fieldValue === undefined || value !== fieldValue) {
if (typeof value === 'number') {
setFieldValue(value);
} else if (field.type === "slug") {
setFieldValue(value);
} else {
setFieldValue(value || null);
}