Skip to content

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.

fix: settings panel breaks when resource url is an expression (#3353)

Bogdan Chadkince8298bf9f03
diff --git a/apps/builder/app/builder/features/settings-panel/variable-popover.tsx b/apps/builder/app/builder/features/settings-panel/variable-popover.tsx
index 36d112fe18..32674b74a8 100644
--- a/apps/builder/app/builder/features/settings-panel/variable-popover.tsx
+++ b/apps/builder/app/builder/features/settings-panel/variable-popover.tsx
@@ -33,7 +33,11 @@ import {
Tooltip,
theme,
} from "@webstudio-is/design-system";
-import { isLocalResource, transpileExpression } from "@webstudio-is/sdk";
+import {
+ executeExpression,
+ isLocalResource,
+ transpileExpression,
+} from "@webstudio-is/sdk";
import type { DataSource } from "@webstudio-is/sdk";
import {
ExpressionEditor,
@@ -388,7 +392,9 @@ const VariablePanel = forwardRef<
const [variableType, setVariableType] = useState<VariableType>(() => {
if (
variable?.type === "resource" &&
- isLocalResource(JSON.parse(resources.get(variable.resourceId)?.url ?? ""))
+ isLocalResource(
+ String(executeExpression(resources.get(variable.resourceId)?.url) ?? "")
+ )
) {
return "system-resource";
}
@@ -642,7 +648,11 @@ export const VariablePopoverTrigger = forwardRef<
variable?.type === "resource" && (
<>
{isLocalResource(
- JSON.parse(resources.get(variable.resourceId)?.url ?? "")
+ String(
+ executeExpression(
+ resources.get(variable.resourceId)?.url
+ ) ?? ""
+ )
) === false && (
<Tooltip
content="Copy resource as cURL command"