Skip to content

Open-source status page, incident response and uptime monitoring

fix: only regenerate slug if there is no default (#236)

Kelvin Amoaba62b080f73a62
diff --git a/apps/web/src/components/forms/status-page-form.tsx b/apps/web/src/components/forms/status-page-form.tsx
index f6d7f0ced..43d134168 100644
--- a/apps/web/src/components/forms/status-page-form.tsx
+++ b/apps/web/src/components/forms/status-page-form.tsx
@@ -64,6 +64,7 @@ export function StatusPageForm({
const inputFileRef = useRef<HTMLInputElement>(null);
const [isPending, startTransition] = useTransition();
const watchSlug = form.watch("slug");
+ const watchTitle = form.watch("title");
const debouncedSlug = useDebounce(watchSlug, 1000); // using debounce to not exhaust the server
const { toast } = useToastAction();
const checkUniqueSlug = useCallback(async () => {
@@ -92,12 +93,11 @@ export function StatusPageForm({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [checkUniqueSlug]);
- // FIXME: 🐛 This is causing a bug
- // useEffect(() => {
- // if (!watchSlug) {
- // form.setValue("slug", slugify(watchTitle));
- // }
- // }, [watchTitle, form, watchSlug]);
+ useEffect(() => {
+ if (!defaultValues?.title) {
+ form.setValue("slug", slugify(watchTitle));
+ }
+ }, [watchTitle, form, defaultValues?.title]);
const onSubmit = async ({
...props