mirror of
https://github.com/estruyf/vscode-front-matter.git
synced 2026-07-05 17:31:22 +02:00
#842 - Allow the slug to be set to an empty value
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user