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
Compute remote style sources only for current breakpoint (#1594)
Bogdan Chadkin888dbbbb0e24
diff --git a/apps/builder/app/builder/features/style-panel/shared/style-info.test.ts b/apps/builder/app/builder/features/style-panel/shared/style-info.test.tsindex 3fc5558c1e..19071cce48 100644--- a/apps/builder/app/builder/features/style-panel/shared/style-info.test.ts+++ b/apps/builder/app/builder/features/style-panel/shared/style-info.test.ts@@ -239,6 +239,13 @@ test("compute styles from previous sources", () => {property: "width",value: { type: "unit", value: 200, unit: "px" },},+ // prevent overriding by value from other breakpoint+ {+ breakpointId: "bp2",+ styleSourceId: "2",+ property: "width",+ value: { type: "unit", value: 250, unit: "px" },+ },{breakpointId: "bp",styleSourceId: "3",@@ -259,7 +266,8 @@ test("compute styles from previous sources", () => {styleSourceSelections,stylesByInstanceId,selectedInstanceSelector,- selectedStyleSourceSelector+ selectedStyleSourceSelector,+ "bp")).toMatchInlineSnapshot(`{@@ -310,6 +318,13 @@ test("compute styles from next sources", () => {property: "width",value: { type: "unit", value: 400, unit: "px" },},+ // prevent overriding by value from other breakpoint+ {+ breakpointId: "bp2",+ styleSourceId: "4",+ property: "width",+ value: { type: "unit", value: 450, unit: "px" },+ },],],]);@@ -318,7 +333,8 @@ test("compute styles from next sources", () => {styleSourceSelections,stylesByInstanceId,selectedInstanceSelector,- selectedStyleSourceSelector+ selectedStyleSourceSelector,+ "bp")).toMatchInlineSnapshot(`{diff --git a/apps/builder/app/builder/features/style-panel/shared/style-info.ts b/apps/builder/app/builder/features/style-panel/shared/style-info.tsindex 9e390fbdec..aad46cb780 100644--- a/apps/builder/app/builder/features/style-panel/shared/style-info.ts+++ b/apps/builder/app/builder/features/style-panel/shared/style-info.ts@@ -14,6 +14,7 @@ import {type Instances,type StyleDecl,type StyleSource as StyleSourceType,+ Breakpoint,} from "@webstudio-is/project-build";import {type StyleSourceSelector,@@ -303,7 +304,8 @@ export const getPreviousSourceInfo = (styleSourceSelections: StyleSourceSelections,stylesByInstanceId: Map<Instance["id"], StyleDecl[]>,selectedInstanceSelector: InstanceSelector,- selectedStyleSourceSelector: StyleSourceSelector+ selectedStyleSourceSelector: StyleSourceSelector,+ breakpointId: Breakpoint["id"]) => {const previousSourceStyle: SourceProperties = {};const [selectedInstanceId] = selectedInstanceSelector;@@ -319,7 +321,10 @@ export const getPreviousSourceInfo = ();// expect instance styles to be orderedfor (const styleDecl of instanceStyles) {- if (previousSourceIds.includes(styleDecl.styleSourceId)) {+ if (+ styleDecl.breakpointId === breakpointId &&+ previousSourceIds.includes(styleDecl.styleSourceId)+ ) {previousSourceStyle[styleDecl.property] = {styleSourceId: styleDecl.styleSourceId,value: styleDecl.value,@@ -333,7 +338,8 @@ export const getNextSourceInfo = (styleSourceSelections: StyleSourceSelections,stylesByInstanceId: Map<Instance["id"], StyleDecl[]>,selectedInstanceSelector: InstanceSelector,- selectedStyleSourceSelector: StyleSourceSelector+ selectedStyleSourceSelector: StyleSourceSelector,+ breakpointId: Breakpoint["id"]) => {const nextSourceStyle: SourceProperties = {};const [selectedInstanceId] = selectedInstanceSelector;@@ -349,7 +355,10 @@ export const getNextSourceInfo = ();// expect instance styles to be orderedfor (const styleDecl of instanceStyles) {- if (nextSourceIds.includes(styleDecl.styleSourceId)) {+ if (+ styleDecl.breakpointId === breakpointId &&+ nextSourceIds.includes(styleDecl.styleSourceId)+ ) {nextSourceStyle[styleDecl.property] = {styleSourceId: styleDecl.styleSourceId,value: styleDecl.value,@@ -442,7 +451,8 @@ export const useStyleInfo = () => {const previousSourceInfo = useMemo(() => {if (selectedInstanceSelector === undefined ||- selectedOrLastStyleSourceSelector === undefined+ selectedOrLastStyleSourceSelector === undefined ||+ selectedBreakpointId === undefined) {return {};}@@ -450,19 +460,22 @@ export const useStyleInfo = () => {styleSourceSelections,stylesByInstanceId,selectedInstanceSelector,- selectedOrLastStyleSourceSelector+ selectedOrLastStyleSourceSelector,+ selectedBreakpointId);}, [styleSourceSelections,stylesByInstanceId,selectedInstanceSelector,selectedOrLastStyleSourceSelector,+ selectedBreakpointId,]);const nextSourceInfo = useMemo(() => {if (selectedInstanceSelector === undefined ||- selectedOrLastStyleSourceSelector === undefined+ selectedOrLastStyleSourceSelector === undefined ||+ selectedBreakpointId === undefined) {return {};}@@ -470,13 +483,15 @@ export const useStyleInfo = () => {styleSourceSelections,stylesByInstanceId,selectedInstanceSelector,- selectedOrLastStyleSourceSelector+ selectedOrLastStyleSourceSelector,+ selectedBreakpointId);}, [styleSourceSelections,stylesByInstanceId,selectedInstanceSelector,selectedOrLastStyleSourceSelector,+ selectedBreakpointId,]);const presetStyle = useMemo(() => {