Rover.fly_to/4 and Rover.fit_to/4 — a view that is a gesture, not state - #4
Merged
Conversation
…ot state `center` and `zoom` are attributes, which is right when the view is a property of what you are rendering. It is the wrong tool for "the user clicked a row, take me there": passing `center` costs you the automatic framing — `fit` falls back to false and the centre stops being derived — so you trade the default behaviour for one gesture and hold the view in assigns from then on. These are commands instead. push_event carries the destination, nothing is assigned, no attribute changes, and because the config never moves the next unrelated re-render cannot pull the view back — which the browser suite asserts by recolouring a parcel after flying and checking the centre held. Both name the map's DOM id, because push_event reaches every hook on the page. Without that filter two maps in one LiveView both fly, so the playground now carries a second map and the suite checks it stayed put. Rover.bbox/1 is public alongside them: markers, shapes, plain coordinates, a mixed list, or a box passed through. It drops coordinates it cannot use rather than raising, for the same reason <.map> does — framing is a convenience and third-party geometry arrives in whatever projection it arrives in. Two of the three new guards were worthless until the sabotage pass caught them: - The fit assertion compared the new zoom `>=` the old one, which is satisfied by doing nothing at all. The playground now fits a single marker with max_zoom: 17, so the assertion is an exact zoom that cannot be reached by inaction — and it covers the max_zoom plumbing as a side effect. - The id filter had nothing to be wrong about with one map on the page. Hence the second map, which also demonstrates a capability nobody had verified. 148 Elixir tests, 48 Node tests, 7 browser scenarios. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.
centerandzoomare attributes, which is right when the view is a property of what you are rendering. It is the wrong tool for "the user clicked a row, take me there": passingcentercosts you the automatic framing (fitfalls back tofalse, the centre stops being derived), so you trade the default behaviour for one gesture and hold the view in assigns from then on.Commands, not state. Nothing assigned, no attribute changed — and because the config never moves, the next unrelated re-render cannot pull the view back. The suite asserts exactly that: fly to Paris, recolour a parcel, check the centre held.
Rover.bbox/1is public alongside them: markers, shapes, plain coordinates, a mixed list, or a box passed through. It drops unusable coordinates rather than raising, matching<.map>.Two of the three new guards were worthless until sabotaged
This is the part worth reading.
>=the old one — satisfied by doing nothing at all. StubbingfitTotoreturnimmediately still passed. The playground now fits a single marker withmax_zoom: 17, so the assertion is an exact zoom that inaction cannot reach, and it covers themax_zoomplumbing as a side effect.All three now fail when broken:
fitTodoes nothingmax_zoomignored148 Elixir tests, 48 Node tests, 7 browser scenarios.
🤖 Generated with Claude Code