Skip to content

Commit 5551451

Browse files
authored
fix: show description in attributes tooltip (#5173)
Description can be taken from attributes meta. Also moved binding warning inside of tooltip to avoid layout shift after binding. <img width="364" alt="Screenshot 2025-04-30 at 17 44 28" src="https://github.com/user-attachments/assets/903d1309-e7af-4d2b-9aa9-7b36bda4f45d" />
1 parent a071280 commit 5551451

2 files changed

Lines changed: 23 additions & 27 deletions

File tree

apps/builder/app/builder/features/settings-panel/property-label.tsx

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,18 @@ import {
1212
rawTheme,
1313
theme,
1414
} from "@webstudio-is/design-system";
15-
import { InfoCircleIcon } from "@webstudio-is/icons";
15+
import { AlertIcon } from "@webstudio-is/icons";
1616
import type { Prop } from "@webstudio-is/sdk";
1717
import { showAttribute } from "@webstudio-is/react-sdk";
1818
import { updateWebstudioData } from "~/shared/instance-utils";
1919
import { $selectedInstance } from "~/shared/awareness";
2020
import { $props, $registeredComponentPropsMetas } from "~/shared/nano-states";
21-
import { humanizeAttribute, showAttributeMeta } from "./shared";
21+
import { $selectedInstancePropsMetas, humanizeAttribute } from "./shared";
2222

2323
const usePropMeta = (name: string) => {
2424
const store = useMemo(() => {
25-
return computed(
26-
[$selectedInstance, $registeredComponentPropsMetas],
27-
(instance, propsMetas) => {
28-
if (name === showAttribute) {
29-
return showAttributeMeta;
30-
}
31-
const metas = propsMetas.get(instance?.component ?? "");
32-
const propMeta = metas?.props[name];
33-
return propMeta;
34-
}
25+
return computed($selectedInstancePropsMetas, (propsMetas) =>
26+
propsMetas.get(name)
3527
);
3628
}, [name]);
3729
return useStore(store);
@@ -144,6 +136,18 @@ export const PropertyLabel = ({
144136
{label}
145137
</Text>
146138
{propMeta?.description && <Text>{propMeta.description}</Text>}
139+
{readOnly && (
140+
<Flex gap="1">
141+
<AlertIcon
142+
color={rawTheme.colors.backgroundAlertMain}
143+
style={{ flexShrink: 0 }}
144+
/>
145+
<Text>
146+
The value is controlled by an expression and cannot be
147+
changed.
148+
</Text>
149+
</Flex>
150+
)}
147151
{isDeletable && (
148152
<Button
149153
color="dark"
@@ -167,17 +171,6 @@ export const PropertyLabel = ({
167171
</Label>
168172
</Tooltip>
169173
</div>
170-
{readOnly && (
171-
<Tooltip
172-
content="The value is controlled by an expression and cannot be changed."
173-
variant="wrapped"
174-
>
175-
<InfoCircleIcon
176-
color={rawTheme.colors.foregroundSubtle}
177-
tabIndex={0}
178-
/>
179-
</Tooltip>
180-
)}
181174
</Flex>
182175
);
183176
};

apps/builder/app/builder/features/settings-panel/shared.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import equal from "fast-deep-equal";
1414
import { ariaAttributes, attributesByTag } from "@webstudio-is/html-data";
1515
import {
1616
reactPropsToStandardAttributes,
17+
showAttribute,
1718
standardAttributesToReactProps,
1819
} from "@webstudio-is/react-sdk";
1920
import {
@@ -498,11 +499,13 @@ export const $selectedInstancePropsMetas = computed(
498499
}
499500
metas.set(name, propMeta);
500501
}
502+
metas.set(showAttribute, showAttributeMeta);
501503
// ui should render in the following order
502-
// 1. component properties
503-
// 2. specific tag attributes
504-
// 3. global html attributes
505-
// 4. aria attributes
504+
// 1. system properties
505+
// 2. component properties
506+
// 3. specific tag attributes
507+
// 4. global html attributes
508+
// 5. aria attributes
506509
return new Map(Array.from(metas.entries()).reverse());
507510
}
508511
);

0 commit comments

Comments
 (0)