mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 07:03:25 +00:00
fix: trim values before form validation
This commit is contained in:
@@ -21,11 +21,13 @@ export default function EditCollectionPage({
|
||||
nextId: collection.nextId,
|
||||
});
|
||||
const canSubmit = useMemo<boolean>(() => {
|
||||
const trimmedName = data.name.trim();
|
||||
const trimmedDescription = data.description?.trim();
|
||||
const isFormEdited =
|
||||
data.name !== collection.name ||
|
||||
data.description !== collection.description ||
|
||||
trimmedName !== collection.name ||
|
||||
trimmedDescription !== collection.description ||
|
||||
data.visibility !== collection.visibility;
|
||||
const isFormValid = data.name !== '';
|
||||
const isFormValid = trimmedName !== '';
|
||||
return isFormEdited && isFormValid && !processing;
|
||||
}, [data, collection]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user