Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions apps/builder/app/builder/shared/css-editor/css-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 ??
Expand Down Expand Up @@ -394,7 +394,7 @@ export const CssEditor = ({
keys: ["property", "value"],
}).map(({ property }) => property);

setSearchProperties(matched as CssProperty[]);
setSearchProperties(matched);
};

const afterChangingStyles = () => {
Expand All @@ -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 && (
Expand All @@ -420,8 +439,8 @@ export const CssEditor = ({
)}
<CssEditorContextMenu
onPaste={handleInsertStyles}
onDeleteProperty={onDeleteProperty}
onDeleteAllDeclarations={onDeleteAllDeclarations}
onDeleteProperty={handleDeleteProperty}
onDeleteAllDeclarations={handleDeleteAllDeclarations}
styleMap={styleMap}
properties={
searchProperties ?? [...recentProperties, ...currentProperties]
Expand All @@ -446,7 +465,7 @@ export const CssEditor = ({
}
}}
onReset={afterChangingStyles}
onDeleteProperty={onDeleteProperty}
onDeleteProperty={handleDeleteProperty}
onSetProperty={onSetProperty}
/>
);
Expand Down Expand Up @@ -493,7 +512,7 @@ export const CssEditor = ({
<LazyRender key={property}>
<AdvancedDeclarationLonghand
property={property}
onDeleteProperty={onDeleteProperty}
onDeleteProperty={handleDeleteProperty}
onSetProperty={onSetProperty}
/>
</LazyRender>
Expand Down