Skip to content

fix(x-select): make .value reflect the current selection#263

Merged
avanelsas merged 1 commit into
mainfrom
fix/x-select-value-reflection
Jun 4, 2026
Merged

fix(x-select): make .value reflect the current selection#263
avanelsas merged 1 commit into
mainfrom
fix/x-select-value-reflection

Conversation

@avanelsas

Copy link
Copy Markdown
Owner

Problem

x-select.value returned the value attribute, which a user selection never updates (only the inner <select> + the dispatched select-change event change). So any consumer reading el.value saw a stale value:

  • The demo's status filter reads (.-value sel) → never sees the selection → looks dead.
  • x-form's collect-values reads (.-value field) at submit and doesn't listen for select-change → forms silently submit the pre-selection value for x-select fields (latent; no e2e selected an option before submitting).

x-select was the only form control like this — x-form-field, x-checkbox, x-date-picker, etc. all make .value/.checked reflect the current value, which is the contract x-form relies on (and native <select>.value behaviour).

Fix

Override x-select's value getter to read the live inner <select>, with one disambiguation: a non-empty value set before its <option> exists (async-loaded options) is surfaced as pending via the attribute until the option arrives and apply-model! selects it.

This preserves both existing tests unmodified:

  • value-attr-not-auto-set-on-change-test — a user change still updates only the inner <select>, never the attribute.
  • string-property-value-testel.value set before options reads back from the attribute.

And adds two regression tests: selection reflection, and set-before-options pending→resolves.

Verification

  • clj-kondo clean
  • full karma 5190 (the two new tests; no x-form/x-select regressions)

Stable-component fix → targets main. (Already cherry-picked onto the alpha branch so the demo's filter works there too.)

🤖 Generated with Claude Code

x-select's `.value` returned the value ATTRIBUTE, which a user selection never updates
(only the inner <select> + the dispatched select-change event changed). So consumers that
read `el.value` — x-form's collect-values, the demo's status filter — saw a stale value:
the filter looked dead, and forms silently submitted the pre-selection value.

Every other BareDOM form control makes `.value`/`.checked` reflect the current value (the
contract x-form relies on); x-select was the lone exception. Override its `value` getter to
read the live inner <select>, with one disambiguation: a non-empty value set BEFORE its
<option> exists (async-loaded options) is surfaced as pending via the attribute until the
option arrives. This preserves both existing tests (value-attr-not-auto-set-on-change,
string-property-value) and adds two regression tests (selection reflection; set-before-options).

clj-kondo clean; full karma 5190.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@avanelsas avanelsas merged commit 15a2552 into main Jun 4, 2026
2 checks passed
avanelsas added a commit that referenced this pull request Jun 4, 2026
Carries the x-select .value-reflection fix (#263) into the write-side
alpha channel. Element surface unchanged from 4.0.0-alpha.0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
avanelsas added a commit that referenced this pull request Jun 10, 2026
Retire BareBuild entirely from the BareDOM repo. Removes the read-side
orchestration elements (barebuild-router / barebuild-route / barebuild-data),
the BareBuild CLI generator + project template, the Phase-4 demo app, all
BareBuild docs, and reverts the alpha (pre-release) dist-tag CI lane (#261).

Removed merged work: #252, #253, #256, #258, #259, #260, #261.
Preserved: #257 (unrelated x-form/x-select fix) and #263 (x-select .value),
which only happened to land in the same window.

The seam was clean (CI-enforced via the now-removed
scripts/check-barebuild-boundary.bb): no non-BareBuild component imported any
BareBuild code, so this is deletion + reference-block edits only.

Reference edits:
- registry.cljs / core.cljs: drop barebuild-registers
- shadow-cljs.edn / package.json: drop the barebuild-* ESM modules + exports
- public/index.html / README.md / docs/components.md: drop the Orchestration
  category (now empty)
- scripts/generate_types.bb / metadata.bb: type only x-* again
- .github/workflows/ci.yml: drop the boundary check + demo-app E2E job
- .github/workflows/release.yml + docs/RELEASING.md: revert the #261 alpha lane
- custom-elements.json: regenerated (no barebuild entries)
- CLAUDE.md / src/baredom/utils/dom.cljs: scrub barebuild from inline examples

Verified: clj-kondo 0/0, release lib 0 warnings, compile test 0 warnings,
npm test 5096 passing, require-style / du-discipline / method-api / bundle-size
guards all green.

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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