Follow-up to the x-select .value fix (#263). Surfaced by the same audit: which form controls' host .value reflects user interaction (what x-form's collect-values reads).
Problem
x-currency-field's value getter (define-value-prop!) reads the value attribute. The native input handler on-input-input keeps ElementInternals.setFormValue current and dispatches event-input, but does not write attr-value — only the change handler on-input-change (blur/Enter) does. So el.value is stale while the user is typing, reconciled only on blur/Enter.
Impact is narrower than x-select:
- Native
<form>/FormData submission is correct (setFormValue stays current on input).
x-form's collect-values reads el.value, so a submit triggered without a prior blur/change (e.g. Enter-to-submit while focused) or any .value read mid-edit gets the stale value. Clicking a submit button normally blurs first → change reconciles → fine.
Fix direction
Mirror the conforming pattern: make el.value reflect the current input. Either
- write
attr-value in on-input-input (as x-otp-input does on every keystroke — but careful not to reformat the focused/in-edit input), or
- make the getter read the live inner
<input>'s raw value (complicated here because the input shows a formatted display value, not the raw value).
Lower priority than #263 — x-currency-field isn't used in the demo, and normal click-submit reconciles via blur. Add a regression test asserting el.value after an input event.
Files: src/baredom/components/x_currency_field/x_currency_field.cljs (define-value-prop!, on-input-input, on-input-change).
Follow-up to the
x-select.valuefix (#263). Surfaced by the same audit: which form controls' host.valuereflects user interaction (whatx-form'scollect-valuesreads).Problem
x-currency-field's value getter (define-value-prop!) reads thevalueattribute. The nativeinputhandleron-input-inputkeepsElementInternals.setFormValuecurrent and dispatchesevent-input, but does not writeattr-value— only thechangehandleron-input-change(blur/Enter) does. Soel.valueis stale while the user is typing, reconciled only on blur/Enter.Impact is narrower than x-select:
<form>/FormDatasubmission is correct (setFormValuestays current on input).x-form'scollect-valuesreadsel.value, so a submit triggered without a prior blur/change (e.g. Enter-to-submit while focused) or any.valueread mid-edit gets the stale value. Clicking a submit button normally blurs first →changereconciles → fine.Fix direction
Mirror the conforming pattern: make
el.valuereflect the current input. Eitherattr-valueinon-input-input(asx-otp-inputdoes on every keystroke — but careful not to reformat the focused/in-edit input), or<input>'s raw value (complicated here because the input shows a formatted display value, not the raw value).Lower priority than #263 —
x-currency-fieldisn't used in the demo, and normal click-submit reconciles via blur. Add a regression test assertingel.valueafter aninputevent.Files:
src/baredom/components/x_currency_field/x_currency_field.cljs(define-value-prop!,on-input-input,on-input-change).