Skip to content

Commit 5cb6295

Browse files
committed
fix: show initial properties in advanced panel (#5157)
Opacity and others when defined are duplicated and not shown at all when not defined. <img width="247" alt="Screenshot 2025-04-23 at 00 18 06" src="https://github.com/user-attachments/assets/70a329eb-c714-4ba8-a839-ca330c30a0f3" />
1 parent abe2711 commit 5cb6295

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

apps/builder/app/builder/features/style-panel/sections/advanced/stores.ts

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,13 @@ import type { ComputedStyleDecl } from "~/shared/style-object-model";
77
import { $computedStyleDeclarations } from "../../shared/model";
88
import { sections } from "../sections";
99

10-
// @todo will be fully deleted https://github.com/webstudio-is/webstudio/issues/4871
11-
const initialProperties = new Set<CssProperty>([
12-
"cursor",
13-
"mix-blend-mode",
14-
"opacity",
15-
"pointer-events",
16-
"user-select",
17-
]);
18-
1910
export const $advancedStyleDeclarations = computed(
2011
[$computedStyleDeclarations, $settings, $selectedInstance],
2112
(computedStyleDeclarations, settings, selectedInstance) => {
22-
const advancedStyles: Array<ComputedStyleDecl> = [];
13+
const advancedStyles = new Map<
14+
ComputedStyleDecl["property"],
15+
ComputedStyleDecl
16+
>();
2317
// All properties used by the panels except the advanced panel
2418
const visualProperties = new Set<CssProperty>([]);
2519
for (const { properties } of sections.values()) {
@@ -37,6 +31,14 @@ export const $advancedStyleDeclarations = computed(
3731
) {
3832
continue;
3933
}
34+
// ignore predefined styles in advanced mode
35+
// @todo will be deleted https://github.com/webstudio-is/webstudio/issues/4871
36+
if (
37+
styleDecl.source.name === "default" &&
38+
settings.stylePanelMode === "advanced"
39+
) {
40+
continue;
41+
}
4042
const { property, listed } = styleDecl;
4143
// When property is listed, it was added from advanced panel.
4244
// If we are in advanced mode, we show them all.
@@ -45,22 +47,10 @@ export const $advancedStyleDeclarations = computed(
4547
listed ||
4648
settings.stylePanelMode === "advanced"
4749
) {
48-
advancedStyles.push(styleDecl);
49-
}
50-
}
51-
// In advanced mode we assume user knows the properties they need, so we don't need to show these.
52-
// @todo https://github.com/webstudio-is/webstudio/issues/4871
53-
if (settings.stylePanelMode !== "advanced") {
54-
for (const property of initialProperties) {
55-
const styleDecl = computedStyleDeclarations.find(
56-
(styleDecl) => styleDecl.property === property
57-
);
58-
if (styleDecl) {
59-
advancedStyles.push(styleDecl);
60-
}
50+
advancedStyles.set(styleDecl.property, styleDecl);
6151
}
6252
}
6353

64-
return advancedStyles;
54+
return Array.from(advancedStyles.values());
6555
}
6656
);

apps/builder/app/builder/features/style-panel/shared/model.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,15 @@ export const $computedStyleDeclarations = computed(
268268
styleSourceSelections,
269269
styles,
270270
});
271+
// In advanced mode we assume user knows the properties they need, so we don't need to show these.
272+
// @todo will be fully deleted https://github.com/webstudio-is/webstudio/issues/4871
273+
definedStyles.push(
274+
{ property: "cursor" },
275+
{ property: "mix-blend-mode" },
276+
{ property: "opacity" },
277+
{ property: "pointer-events" },
278+
{ property: "user-select" }
279+
);
271280
const computedStyles = new Map<string, ComputedStyleDecl>();
272281
for (const { property, listed } of definedStyles) {
273282
// deduplicate by property name

0 commit comments

Comments
 (0)