Skip to content

feat!: multiple selection (v4.0.0) - #5

Merged
michaeljfalk merged 1 commit into
mainfrom
feat/4.0.0-multi-select
Jun 17, 2026
Merged

michaeljfalk merged 1 commit into
mainfrom
feat/4.0.0-multi-select

Conversation

@michaeljfalk

Copy link
Copy Markdown
Owner

Summary

The headline feature: multiple selection via multiple: true. The major version marks the size of the addition — single-select behavior is unchanged and there are no breaking changes (everything new is gated behind the flag).

Multiple selection

  • Chips for each selection. Add by clicking a row or typing + Enter; remove via a chip's × or Backspace on an empty input; re-selecting a chosen row toggles it off.
  • Array value throughout: getValue() → string[], getOption() → option[], onChange(values, options), setValue([...]), and liveselect:change detail { name, value: [], options: [] }.
  • maxItems caps selections and suppresses the create row at the cap.
  • submitFormat controls plain-form submission: 'repeat' (default — one hidden input per value sharing the name, exactly like native <select multiple>, so Express parses req.body.tags as an array), 'bracket' (name[], PHP/Rails), or 'delimited' (one input joined by delimiter).
  • A11y: chosen rows get aria-selected + .liveselect__opt--chosen; the listbox is aria-multiselectable.
  • enhance() auto-detects <select multiple>, upgrades to multi mode, and keeps the original element's selected options in sync.

Changes

  • dist/liveselect.js — multi state; chips container + per-submitFormat hidden inputs; _toggle/_deselect/_renderTags/_afterMultiChange/_syncHiddenMulti; multi branches in _select/_emit/_syncInput/_syncHidden/_syncValidity/_canCreate/getValue/getOption/setValue/clear; Backspace-to-remove; chosen-row marking; enhance() multi support
  • dist/liveselect.css — chips/control layout, chosen-row checkmark
  • test/client.test.js — 9 new tests → 45/45 pass
  • README.md — Multiple selection section, options table, Events/Instance API notes, Features bullets
  • examples/vanilla.html — multi-select demo (section 6)
  • CHANGELOG.md + package.json — bump to 4.0.0

Test plan

  • npm test → 45/45 (was 36); all single-select regressions (XSS, a11y, validation, groups, etc.) still pass
  • Core + example inline script parse clean

🤖 Generated with Claude Code

Headline feature: multi-select via `multiple: true`. Major version marks the
size; single-select behavior is unchanged (everything new is gated behind the
flag — no breaking changes).

- Selections render as removable chips. Add by click or type+Enter; remove via
  chip × or Backspace on empty input; re-selecting a chosen row toggles it off.
- Array value throughout: getValue() → string[], getOption() → option[],
  onChange(values, options), setValue([...]), change detail { value: [], options: [] }.
- maxItems caps selections (and suppresses the create row at the cap).
- submitFormat ('repeat' default | 'bracket' | 'delimited' + delimiter) controls
  plain-form submission; 'repeat' mirrors native <select multiple>.
- Chosen rows get aria-selected + __opt--chosen; listbox is aria-multiselectable.
- enhance() auto-detects <select multiple>, upgrades to multi, and keeps the
  original element's selected options in sync.

9 new jsdom tests (45 total), CSS for chips/chosen rows, README (Multiple
selection section, options table, Events/Instance API notes, Features bullets),
a multi-select demo in examples/vanilla.html, CHANGELOG + version bump to 4.0.0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@michaeljfalk
michaeljfalk merged commit a99f41a into main Jun 17, 2026
5 checks passed
@michaeljfalk
michaeljfalk deleted the feat/4.0.0-multi-select branch June 17, 2026 18:51
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