Repository navigation
fix(ui): stop re-renders from scrolling the page back to CSelect, CTabs and others - #406
Merged
Merged
Conversation
…bs and others The #383 fix found that CMenu scrolled the page back to itself whenever it refocused an item. A browser test for each other component that calls scrollIntoView or focus() without a key press confirmed the same on main for six of them. The reader scrolls the page away, then: - CSelect and CMultiSelect: a re-render while the popup is open reopens it and shows the highlighted option with scrollIntoView; - CCombobox: new items move the active option, which the shared active-option code shows with scrollIntoView; - CTabs: a re-render that removes the selected tab shows the fallback tab with scrollIntoView; - CTagGroup and CToolbar: a re-render that removes the focused item moves focus with focus(). CSelect, CMultiSelect, CCombobox and CTabs now scroll only their own list, through a shared runtime (components/_reveal.py) that scrolls the scrollable elements from an element up to its container by the least distance. CSelect runs it before its open animation scales the popup. CTagGroup moves focus with preventScroll, and CToolbar also scrolls only itself to show the replacement. Arrow-key and typeahead moves in CSelect and CMultiSelect keep scrollIntoView; CTabs keyboard moves still scroll through focus(). CCommandPalette is modal, so a page with only the palette keeps scrollIntoView and does not load the new runtime. Every other popup that leaves the page free to scroll passed the same re-render test on main, so it is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 25, 2026
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 #383 and #395. That fix found that
CMenuscrolled the page back to itself whenever it refocused an item. This PR checks the other components that callscrollIntoVieworfocus()on a path that runs without a key press. Each one has a browser test that scrolls the page away and then triggers that path. Only the cases a test confirmed on main are fixed.Confirmed on main, and fixed
scrollYon main (from 3000)CSelectCMultiSelectCComboboxCTabsCTagGroupfocus({ preventScroll: true })CToolbarfocus({ preventScroll: true }), then scrolls only the toolbarThe shared runtime is new, in
components/_reveal.py. It's stored onglobalThisunderSymbol.for('citry-ui:reveal')and loaded throughDependencies, like_scroll_geometry.py, and it's written short by hand, like that one, because every page with one of these components downloads it.reveal(element, container)scrolls only the scrollable elements from the element up to and includingcontainer, by the least distance that shows it. It does nothing when the element isn't inside the container, or is the container itself.runtime.min.jsis rebuilt.scrollIntoView, because a key press means the reader is at the component. CTabs keyboard moves still scroll throughfocus().CCommandPaletteis modal and locks the page's scrolling. A page with only the palette doesn't load the new runtime, and the shared active-option code keepsscrollIntoViewthere. This also keeps the command-palette family under its byte budgets.Cleared
Every other popup that leaves the page free to scroll passes the new parametrized re-render test on main:
cmenu,cpopover,chover_card,ccombobox(its re-render path; the new-items path is fixed above),ccascader,ccolor_picker, the date and time pickers andctour. The test istest_server_rerender_of_an_open_overlay_leaves_the_page_where_the_reader_scrolled. While it ran, I logged everyscrollIntoViewandfocus()call: these components either make none on that path or passpreventScroll. Modal dialogs lock the page's scrolling, so they don't take part.Not checked (out of scope)
CTransferList: in controlled mode, the owner's value can arrive after a server round trip (runtime.source.js:451), andfocusMovedthen callsscrollIntoView. I found this by reading the code and didn't test it.CCascader: a controlled open callsitem.focus()withoutpreventScroll. That's probably intended when the owner opens the popup.Tests
citry_ui/tests/e2e/test_open_state_across_server_rerender_e2e.py.v-ifon their test page, so a Vue re-render can remove the focused item.cselect/.../test_opening_shows_the_highlighted_option_inside_the_listchecks that the list still scrolls to show a selected option far down, fully inside the popup. It fails on an earlier draft of this change that ranrevealafter the animation started.Evidence (local, with citry_core built from main 5a4e517)
Suites for the touched components, the re-render tests and the asset tests: 529 passed.
The one failure is
test_context_menu_assets_stay_within_the_family_budgets, which fails on main too and is fixed by fix(ui): bring the context-menu family back under its byte budgets #401.Byte budgets (family JS, gzip and brotli), main → this PR:
All are within budget. The command-palette brotli figure is the tightest spot, with about 55 bytes of room, so the next edit to
_active_descendant.pywill likely need to shorten something there.All the local check phases pass, including
citry-ui assets,docs-playgroundandvscode-extension.PR CI runs the cargo phases and the full matrix.
🤖 Generated with Claude Code