From 50c76eac0fefdaa8fc77bfa3b8169619eb9c7c24 Mon Sep 17 00:00:00 2001 From: Oleg Isonen Date: Wed, 5 Mar 2025 20:30:25 +0000 Subject: [PATCH 1/2] when deleteing property during search - remove it from results --- .../builder/shared/css-editor/css-editor.tsx | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/apps/builder/app/builder/shared/css-editor/css-editor.tsx b/apps/builder/app/builder/shared/css-editor/css-editor.tsx index 1900fa0e6885..15f71059f489 100644 --- a/apps/builder/app/builder/shared/css-editor/css-editor.tsx +++ b/apps/builder/app/builder/shared/css-editor/css-editor.tsx @@ -407,6 +407,22 @@ export const CssEditor = ({ }); }; + const handleDeleteProperty = (property: CssProperty) => { + setSearchProperties( + searchProperties?.filter((searchProperty) => searchProperty !== property) + ); + onDeleteProperty(property); + }; + + const handleDeleteAllDeclarations = (styleMap: CssStyleMap) => { + setSearchProperties( + searchProperties?.filter( + (searchProperty) => styleMap.has(searchProperty) === false + ) + ); + onDeleteAllDeclarations(styleMap); + }; + return ( <> {showSearch && ( @@ -420,8 +436,8 @@ export const CssEditor = ({ )} Date: Wed, 5 Mar 2025 20:37:00 +0000 Subject: [PATCH 2/2] also delete from search result when deleting via property --- .../app/builder/shared/css-editor/css-editor.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/builder/app/builder/shared/css-editor/css-editor.tsx b/apps/builder/app/builder/shared/css-editor/css-editor.tsx index 15f71059f489..77bf4fc60433 100644 --- a/apps/builder/app/builder/shared/css-editor/css-editor.tsx +++ b/apps/builder/app/builder/shared/css-editor/css-editor.tsx @@ -340,7 +340,7 @@ export const CssEditor = ({ }, })); - const advancedProperties = Array.from(styleMap.keys()) as Array; + const advancedProperties = Array.from(styleMap.keys()); const currentProperties = searchProperties ?? @@ -394,7 +394,7 @@ export const CssEditor = ({ keys: ["property", "value"], }).map(({ property }) => property); - setSearchProperties(matched as CssProperty[]); + setSearchProperties(matched); }; const afterChangingStyles = () => { @@ -407,11 +407,14 @@ export const CssEditor = ({ }); }; - const handleDeleteProperty = (property: CssProperty) => { + const handleDeleteProperty: DeleteProperty = (property, options = {}) => { + onDeleteProperty(property, options); + if (options.isEphemeral === true) { + return; + } setSearchProperties( searchProperties?.filter((searchProperty) => searchProperty !== property) ); - onDeleteProperty(property); }; const handleDeleteAllDeclarations = (styleMap: CssStyleMap) => { @@ -462,7 +465,7 @@ export const CssEditor = ({ } }} onReset={afterChangingStyles} - onDeleteProperty={onDeleteProperty} + onDeleteProperty={handleDeleteProperty} onSetProperty={onSetProperty} /> ); @@ -509,7 +512,7 @@ export const CssEditor = ({