Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import {
$selectedPage,
} from "~/shared/awareness";
import { updateWebstudioData } from "~/shared/instance-utils";
import { restoreTreeVariablesMutable } from "~/shared/data-variables";
import { rebindTreeVariablesMutable } from "~/shared/data-variables";

const validateUrl = (value: string, scope: Record<string, unknown>) => {
const evaluatedValue = evaluateExpressionWithinScope(value, scope);
Expand Down Expand Up @@ -608,7 +608,7 @@ export const ResourceForm = forwardRef<
updateWebstudioData((data) => {
data.dataSources.set(newVariable.id, newVariable);
data.resources.set(newResource.id, newResource);
restoreTreeVariablesMutable({ instancePath, ...data });
rebindTreeVariablesMutable({ instancePath, ...data });
});
},
}));
Expand Down Expand Up @@ -740,7 +740,7 @@ export const SystemResourceForm = forwardRef<
updateWebstudioData((data) => {
data.dataSources.set(newVariable.id, newVariable);
data.resources.set(newResource.id, newResource);
restoreTreeVariablesMutable({ instancePath, ...data });
rebindTreeVariablesMutable({ instancePath, ...data });
});
},
}));
Expand Down Expand Up @@ -856,7 +856,7 @@ export const GraphqlResourceForm = forwardRef<
updateWebstudioData((data) => {
data.dataSources.set(newVariable.id, newVariable);
data.resources.set(newResource.id, newResource);
restoreTreeVariablesMutable({ instancePath, ...data });
rebindTreeVariablesMutable({ instancePath, ...data });
});
},
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ import { generateCurl } from "./curl";
import { updateWebstudioData } from "~/shared/instance-utils";
import {
findUnsetVariableNames,
restoreTreeVariablesMutable,
rebindTreeVariablesMutable,
} from "~/shared/data-variables";

const $variablesByName = computed(
Expand Down Expand Up @@ -299,7 +299,7 @@ const ParameterForm = forwardRef<
const name = z.string().parse(formData.get("name"));
updateWebstudioData((data) => {
data.dataSources.set(variable.id, { ...variable, name });
restoreTreeVariablesMutable({ instancePath, ...data });
rebindTreeVariablesMutable({ instancePath, ...data });
});
},
}));
Expand Down Expand Up @@ -339,7 +339,7 @@ const useValuePanelRef = ({
type: "variable",
value: variableValue,
});
restoreTreeVariablesMutable({ instancePath, ...data });
rebindTreeVariablesMutable({ instancePath, ...data });
});
},
}));
Expand Down
10 changes: 8 additions & 2 deletions apps/builder/app/builder/shared/binding-popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ import {
lintExpression,
} from "@webstudio-is/sdk";
import { $dataSourceVariables, $isDesignMode } from "~/shared/nano-states";
import { computeExpression } from "~/shared/data-variables";
import {
computeExpression,
encodeDataVariableName,
} from "~/shared/data-variables";
import {
ExpressionEditor,
formatValuePreview,
Expand Down Expand Up @@ -146,7 +149,10 @@ const BindingPanel = ({
active={usedIdentifiers.has(identifier)}
// convert variable to expression
onClick={() => {
editorApiRef.current?.replaceSelection(identifier);
if (name) {
const nameIdentifier = encodeDataVariableName(name);
editorApiRef.current?.replaceSelection(nameIdentifier);
}
}}
// expression editor blur is fired after pointer down even
// preventing it allows to not trigger validation
Expand Down
Loading