Skip to content

Reuse an existing attribute when a variation card is renamed to its name - #372

Merged
ahamed merged 1 commit into
devfrom
fix/variations
Oct 15, 2026
Merged

ahamed merged 1 commit into
devfrom
fix/variations

Conversation

@ahamed

@ahamed ahamed commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Typing the name of an existing attribute in a product variation card now loads that attribute instead of showing a blocking duplicate-name error.
  • Picking a color in a value chip's color picker no longer closes the picker and opens the values dropdown.

Name reuse

On blur of the name input, a name that matches an existing store attribute (trimmed, case-insensitive) is handled by what is selected:

Situation Result
No values selected Card switches to that attribute: its values, type and stored name load. Works for + Add new, presets, + Add picks and editing an applied attribute (Apply then replaces the old attribute, no new attribute is created).
Values selected "An attribute with this name already exists."
Attribute already on this product "This attribute is already added to this product." Nothing loads.
Unique new name, values selected New attribute with copies of the values (colors too). The original keeps its values.
Unique new name, none selected Previous options stay available.

The name check is one shared classifier, used by the name input and by the Apply backstop, so the two cannot disagree.

Color picker

Events from the portalled picker bubbled through React to the MultiSelect box click handler, which opened the values dropdown and dismissed the picker. The click that dismissed the picker could also open the dropdown.

  • MultiSelect ignores box clicks whose target is outside its DOM.
  • MultiSelect skips the open click that follows a pointer down while a chip layer was open. The signal is opt-in (useMultiSelectChipLayer), so other MultiSelect users are unchanged.

Testing

  • eslint on features/products and components/ui: clean.
  • vitest on features/products and components/ui: 374 tests pass. New tests cover each name case, the copy-not-move behavior, and the color picker. The two picker tests fail without the MultiSelect fix.
  • Not run in a browser. Please check the color picker and the name reuse visually.
  • Unrelated and already present: 3 features/settings test files fail because settings-search-index.json is missing, and tsc reports ColumnMeta errors in data-table and bulk-edit files.

Includes the archived OpenSpec change reuse-existing-attribute-on-rename and the synced product-variations-card spec.

Typing the name of an existing attribute in a product variation card used
to show a blocking duplicate-name error. Now, on blur, the card switches to
that attribute when no values are selected: its values, type and stored name
load, and Apply uses it (replacing the applied attribute when editing one).

- Name matches an existing attribute while values are selected: keep the
  "An attribute with this name already exists." error.
- Name matches an attribute already on the product: show "This attribute is
  already added to this product." and load nothing.
- Unique new name with selected values: still creates a new attribute with
  copies of the values; the original keeps its values. Covered by tests.
- The name check is one shared classifier used by the name input and Apply.

Also fix the chip color picker in the value field. Picking a color closed the
picker and opened the values dropdown, because picker events bubble through
the React portal to the MultiSelect box click handler, and the dismissing
click then opened the panel. MultiSelect now ignores clicks from outside its
DOM and skips the open click that follows a chip layer being dismissed.
The chip layer signal is opt-in, so other MultiSelect users are unchanged.

Includes the OpenSpec change, archived, and the synced
product-variations-card spec.
@ahamed
ahamed merged commit 97ba809 into dev Oct 15, 2026
6 checks passed
@ahamed
ahamed deleted the fix/variations branch October 15, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant