From 30ecb4d83247441bb86038e03ee389ee85db6fe7 Mon Sep 17 00:00:00 2001 From: RitaDias Date: Fri, 12 Jul 2024 13:17:09 +0200 Subject: [PATCH] chore(sanity): clean up --- .../bundles/components/dialog/BundleForm.tsx | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/packages/sanity/src/core/bundles/components/dialog/BundleForm.tsx b/packages/sanity/src/core/bundles/components/dialog/BundleForm.tsx index f13e817d223..fe4ddf143ec 100644 --- a/packages/sanity/src/core/bundles/components/dialog/BundleForm.tsx +++ b/packages/sanity/src/core/bundles/components/dialog/BundleForm.tsx @@ -110,21 +110,14 @@ export function BundleForm(props: { [icon, hue], ) - const titleHasErrors = useCallback( - (pickedTitle: string) => { - return Boolean( - isDraftOrPublished(pickedTitle) || // title cannot be "drafts" or "published" - data?.find((bundle) => bundle.name === speakingurl(pickedTitle)), // bundle already exists - ) - }, - [data], - ) - const handleBundleTitleChange = useCallback( (event: React.ChangeEvent) => { const pickedTitle = event.target.value - if (titleHasErrors(pickedTitle)) { + if ( + isDraftOrPublished(pickedTitle) || + data?.find((bundle) => bundle.name === speakingurl(pickedTitle)) + ) { if (isDraftOrPublished(pickedTitle)) { setShowIsDraftPublishError(true) } else { @@ -146,7 +139,7 @@ export function BundleForm(props: { setIsInitialRender(false) onChange({...value, title: pickedTitle, name: speakingurl(pickedTitle)}) }, - [data, onChange, onError, titleHasErrors, value], + [data, onChange, onError, value], ) const handleBundleDescriptionChange = useCallback(