Skip to content

Commit 315c848

Browse files
authored
fix: on pasting in advanced panel, show warning toast for duplicate variables and continue updating the values (#5623)
1 parent 348d049 commit 315c848

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

apps/builder/app/builder/shared/css-editor/add-style-input.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,16 @@ export const AddStyleInput = forwardRef<
234234
if (property.startsWith("--")) {
235235
const error = validateCssVariableName(property);
236236
if (error) {
237-
// Show error via toast
238-
toast.error(error.message);
239-
return;
237+
// For duplicate variables, show warning and continue updating the values
238+
if (error.type === "duplicate") {
239+
toast.warn(
240+
`CSS variable "${property}" already exists. Its value will be updated.`
241+
);
242+
} else {
243+
// Show error via toast and block submission
244+
toast.error(error.message);
245+
return;
246+
}
240247
}
241248
}
242249

apps/builder/app/builder/shared/css-variable-utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export const $unusedCssVariables = computed(
270270
}
271271
);
272272

273-
export type CssVariableError =
273+
type CssVariableError =
274274
| { type: "required"; message: string }
275275
| { type: "invalid"; message: string }
276276
| { type: "duplicate"; message: string };

0 commit comments

Comments
 (0)