Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

fix: When deleting property during search in advanced panel - remove it from results (#4950)

Oleg Isonend5edc483ea80
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 1900fa0e68..77bf4fc604 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<CssProperty>;
+ 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,6 +407,25 @@ export const CssEditor = ({
});
};
+ const handleDeleteProperty: DeleteProperty = (property, options = {}) => {
+ onDeleteProperty(property, options);
+ if (options.isEphemeral === true) {
+ return;
+ }
+ setSearchProperties(
+ searchProperties?.filter((searchProperty) => searchProperty !== property)
+ );
+ };
+
+ const handleDeleteAllDeclarations = (styleMap: CssStyleMap) => {
+ setSearchProperties(
+ searchProperties?.filter(
+ (searchProperty) => styleMap.has(searchProperty) === false
+ )
+ );
+ onDeleteAllDeclarations(styleMap);
+ };
+
return (
<>
{showSearch && (
@@ -420,8 +439,8 @@ export const CssEditor = ({
)}
<CssEditorContextMenu
onPaste={handleInsertStyles}
- onDeleteProperty={onDeleteProperty}
- onDeleteAllDeclarations={onDeleteAllDeclarations}
+ onDeleteProperty={handleDeleteProperty}
+ onDeleteAllDeclarations={handleDeleteAllDeclarations}
styleMap={styleMap}
properties={
searchProperties ?? [...recentProperties, ...currentProperties]
@@ -446,7 +465,7 @@ export const CssEditor = ({
}
}}
onReset={afterChangingStyles}
- onDeleteProperty={onDeleteProperty}
+ onDeleteProperty={handleDeleteProperty}
onSetProperty={onSetProperty}
/>
);
@@ -493,7 +512,7 @@ export const CssEditor = ({
<LazyRender key={property}>
<AdvancedDeclarationLonghand
property={property}
- onDeleteProperty={onDeleteProperty}
+ onDeleteProperty={handleDeleteProperty}
onSetProperty={onSetProperty}
/>
</LazyRender>