Repository navigation
Add LineGraph and Slider repros for {bind} vs accessor-chain default seeding - #1338
Merged
Merged
Conversation
Accessor-chain bindings don't get the declared prop default written to the
store, unlike {bind} objects. A chain-bound LineGraph starts hidden
(active undefined) and a chain-bound Slider positions its handle at NaN%
and writes NaN on mouse wheel. The specs pin down the current behavior;
the litmus page shows each widget side by side with both binding styles.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #1336, for #1337. That PR only covered form fields. The same gap affects every widget prop with a declared default: a
{bind}object writes that default to the store, and an accessor chain leaves itundefined. With charts and sliders, that does more than change the stored value. It changes what you see and what gets saved:active: true): a series bound withactive={m.$page.show}isn't drawn while the store is empty, because LineGraph renders nothing whenactiveis falsy. The same series bound with{bind}is drawn. The legend shows the hidden series as on, and clicking it draws the series (the toggle writes!undefined, which istrue).to: 0): a chain-bound slider calculates its handle position fromundefinedand rendersleft: NaN%. The browser ignores that value, so the handle only looks right by accident. Scrolling the mouse wheel writesNaNto the store (undefined + step).Changes
charts/LineGraph.spec.tsx, 4 cases:{bind}draws the line and storestrue; the chain stores nothing and draws no line; the legend entry still shows as on; the chain draws once the store holdstrue. react-test-renderer has no DOM for the Svg to measure, so the spec uses a smallFixedSizeSvgsubclass with a fixed size.widgets/form/Slider.spec.tsx, 4 cases: the handle position (0%vsNaN%) and the mouse wheel step (1vsNaN). It usescreateNodeMockto capture the wheel listener.litmus/bugs/FieldBindingObjectNullSeeding: rebuilt so it explains itself. TextField, LineGraph and Slider each appear side by side with both binding styles, with a live readout of each store value and notes on what you should see and what actually happens.No behavior changes. Like #1336, the specs check the current behavior, and the fix PR will update them to the intended behavior.
🤖 Generated with Claude Code