add live validation for page handler (#10491)

This commit is contained in:
Kartik Gupta 2024-07-31 15:15:39 +05:30 committed by GitHub
parent 5bb033f7e3
commit 915b91297c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,6 @@
import React, { useState } from 'react';
import { ToolTip } from '@/Editor/Inspector/Elements/Components/ToolTip';
import { validateKebabCase } from '@/_helpers/utils';
export const EditInput = ({ slug, error, setError, pageHandle, setPageHandle, isSaving = false }) => {
const [value, set] = useState(pageHandle);
@ -10,7 +11,10 @@ export const EditInput = ({ slug, error, setError, pageHandle, setPageHandle, is
if (newHandle === '') setError('Page handle cannot be empty');
if (newHandle === value) setError('Page handle cannot be same as the existing page handle');
const isValidKebabCase = validateKebabCase(newHandle);
if (!isValidKebabCase.isValid) {
setError(isValidKebabCase.error);
}
set(newHandle);
};