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: remove "show" toggles on descendant component (#4711)
Bogdan Chadkin85147c81e66e
diff --git a/.github/workflows/fixtures-test.yml b/.github/workflows/fixtures-test.ymlindex 7d77b098c2..e6cd2f0c2d 100644--- a/.github/workflows/fixtures-test.yml+++ b/.github/workflows/fixtures-test.yml@@ -50,6 +50,9 @@ jobs:- name: Testing cli build commandrun: pnpm --filter='./fixtures/*' run --parallel fixtures:build+ - name: Prepare for diffing+ run: find . -type f -path "./fixtures/*/.webstudio/data.json" -exec sed 's|"origin": ".*"|"origin": "https://main.development.webstudio.is"|g' {} ++- name: Test git diff# This command will fail if there are uncommitted changes, i.e something has brokenrun: git diff --name-only HEAD --exit-codediff --git a/apps/builder/app/builder/features/navigator/navigator-tree.tsx b/apps/builder/app/builder/features/navigator/navigator-tree.tsxindex 8dd37621d1..961ed603df 100644--- a/apps/builder/app/builder/features/navigator/navigator-tree.tsx+++ b/apps/builder/app/builder/features/navigator/navigator-tree.tsx@@ -26,6 +26,7 @@ import {showAttribute,WsComponentMeta,blockTemplateComponent,+ descendantComponent,} from "@webstudio-is/react-sdk";import { ROOT_INSTANCE_ID, type Instance } from "@webstudio-is/sdk";import {@@ -281,22 +282,28 @@ const handleExpand = (item: TreeItem, isExpanded: boolean, all: boolean) => {};const ShowToggle = ({- instanceId,+ instance,value,}: {- instanceId: Instance["id"];+ instance: Instance;value: boolean;}) => {+ // descendant component is not actually rendered+ // but affects styling of nested elements+ // hiding descendant does not hide nested elements and confuse users+ if (instance.component === descendantComponent) {+ return;+ }const toggleShow = () => {const newValue = value === false;serverSyncStore.createTransaction([$props], (props) => {const { propsByInstanceId } = $propsIndex.get();- const instanceProps = propsByInstanceId.get(instanceId);+ const instanceProps = propsByInstanceId.get(instance.id);let showProp = instanceProps?.find((prop) => prop.name === showAttribute);if (showProp === undefined) {showProp = {id: nanoid(),- instanceId,+ instanceId: instance.id,name: showAttribute,type: "boolean",value: newValue,@@ -660,9 +667,7 @@ export const NavigatorTree = () => {}},}}- action={- <ShowToggle instanceId={item.instance.id} value={show} />- }+ action={<ShowToggle instance={item.instance} value={show} />}><TreeNodeContentmeta={meta}diff --git a/apps/builder/app/builder/features/settings-panel/props-section/use-props-logic.ts b/apps/builder/app/builder/features/settings-panel/props-section/use-props-logic.tsindex 62e153a0d9..f11fc11894 100644--- a/apps/builder/app/builder/features/settings-panel/props-section/use-props-logic.ts+++ b/apps/builder/app/builder/features/settings-panel/props-section/use-props-logic.ts@@ -5,6 +5,7 @@ import {showAttribute,textContentAttribute,collectionComponent,+ descendantComponent,} from "@webstudio-is/react-sdk";import type { PropValue } from "../shared";import { useStore } from "@nanostores/react";@@ -195,19 +196,32 @@ export const usePropsLogic = ({const initialPropsNames = new Set(meta.initialProps ?? []);- const systemProps: PropAndMeta[] = systemPropsMeta.map(({ name, meta }) => {- let saved = getAndDelete<Prop>(unprocessedSaved, name);- if (saved === undefined && meta.defaultValue !== undefined) {- saved = getStartingProp(instance.id, meta, name);- }- getAndDelete(unprocessedKnown, name);- initialPropsNames.delete(name);- return {- prop: saved,- propName: name,- meta,- };- });+ const systemProps: PropAndMeta[] = systemPropsMeta+ .filter(({ name }) => {+ // descendant component is not actually rendered+ // but affects styling of nested elements+ // hiding descendant does not hide nested elements and confuse users+ if (+ instance.component === descendantComponent &&+ name === showAttribute+ ) {+ return false;+ }+ return true;+ })+ .map(({ name, meta }) => {+ let saved = getAndDelete<Prop>(unprocessedSaved, name);+ if (saved === undefined && meta.defaultValue !== undefined) {+ saved = getStartingProp(instance.id, meta, name);+ }+ getAndDelete(unprocessedKnown, name);+ initialPropsNames.delete(name);+ return {+ prop: saved,+ propName: name,+ meta,+ };+ });const canHaveTextContent =instanceMeta?.type === "container" &&