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.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
Fix instance labels in settings and style panel tooltips (#2164)
Bogdan Chadkin1bb154eebdf4
diff --git a/apps/builder/app/builder/features/settings-panel/settings-section/settings-section.tsx b/apps/builder/app/builder/features/settings-panel/settings-section/settings-section.tsxindex 2090fba7b5..9f8347eb1f 100644--- a/apps/builder/app/builder/features/settings-panel/settings-section/settings-section.tsx+++ b/apps/builder/app/builder/features/settings-panel/settings-section/settings-section.tsx@@ -6,6 +6,7 @@ import {} from "~/shared/nano-states";import { useSettingsLogic } from "./use-settings-logic";import { HorizontalLayout, Row } from "../shared";+import { getInstanceLabel } from "~/shared/instance-utils";export const SettingsSection = () => {const { setLabel, handleBlur, handleKeyDown } = useSettingsLogic();@@ -14,7 +15,11 @@ export const SettingsSection = () => {if (selectedInstance === undefined) {return null;}- const label = metas.get(selectedInstance.component)?.label;+ const meta = metas.get(selectedInstance.component);+ if (meta === undefined) {+ return null;+ }+ const placeholder = getInstanceLabel(selectedInstance, meta);return (<Row><HorizontalLayout label="Name">@@ -23,7 +28,7 @@ export const SettingsSection = () => {key={selectedInstance.id}onBlur={handleBlur}onKeyDown={handleKeyDown}- placeholder={label}+ placeholder={placeholder}defaultValue={selectedInstance.label}onChange={(event) => {setLabel(event.target.value.trim());diff --git a/apps/builder/app/builder/features/style-panel/shared/property-name.tsx b/apps/builder/app/builder/features/style-panel/shared/property-name.tsxindex ded9422a75..17c5aa38a7 100644--- a/apps/builder/app/builder/features/style-panel/shared/property-name.tsx+++ b/apps/builder/app/builder/features/style-panel/shared/property-name.tsx@@ -25,6 +25,7 @@ import { toProperty } from "@webstudio-is/css-engine";import {breakpointsStore,instancesStore,+ registeredComponentMetasStore,selectedBreakpointStore,selectedInstanceStore,selectedStyleSourceStore,@@ -36,6 +37,7 @@ import {type StyleValueInfo,} from "./style-info";import { humanizeString } from "~/shared/string-utils";+import { getInstanceLabel } from "~/shared/instance-utils";import { StyleSourceBadge } from "../style-source";// We don't return source name only in case of preset or default value.@@ -133,6 +135,7 @@ const TooltipContent = ({const instances = useStore(instancesStore);const styleSources = useStore(styleSourcesStore);const instance = useStore(selectedInstanceStore);+ const metas = useStore(registeredComponentMetasStore);const selectedStyleSource = useStore(selectedStyleSourceStore);const descriptionWithFallback = description ?? getDescription(properties);@@ -166,10 +169,21 @@ const TooltipContent = ({breakpointSet.add(`${breakpointName}`);- let instanceTitle = instance?.label ?? instance?.component;+ let instanceTitle: undefined | string;+ if (instance) {+ const meta = metas.get(instance.component);+ if (meta) {+ instanceTitle = getInstanceLabel(instance, meta);+ }+ }if (styleValueInfo.inherited && styleValueInfo.local === undefined) {const localInstance = instances.get(styleValueInfo.inherited.instanceId);- instanceTitle = localInstance?.label ?? localInstance?.component;+ if (localInstance) {+ const meta = metas.get(localInstance.component);+ if (meta) {+ instanceTitle = getInstanceLabel(localInstance, meta);+ }+ }}if (instanceTitle !== undefined) {