Repository navigation
fix: Stack takes part in focus traversal; ListBox clips wide rows - #482
Merged
Merged
Conversation
Stack held its pages in a map and exposed neither Children nor focusableChildren, so every walk stopped at it: an Entry on a Stack page was clicked into focus inside the page while the window's focus list, which never reached it, received the typed keys and dropped them; and a DropDown on a Stack page opened a popover PopoverHost could not see. Stack now yields its VISIBLE page to both walks, and routes keyboard events and click-to-focus through the focus system as Container does. Hidden pages are deliberately not yielded: they keep the Stack's bounds, so a bounds check cannot exclude them the way it excludes an inactive CardLayout card. TestEveryContainerExposesItsChildren now also treats a map of widgets as a holder; it is the gap that let Stack through. Fixes #480 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ListBox pushed its clip only while the list overflowed vertically, so a short list drew a row wider than itself past its right edge, a host ItemRenderer included. The clip is now pushed whenever the painter can clip; it is the same content rect, so the overflowing case is unchanged. Fixes #481 Co-Authored-By: Claude Opus 5.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.
Two small fixes found while building the claimward Linux and Windows apps, one commit each.
Stack (#480)
Root cause.
Stackkeeps its pages in amap[string]Widgetand exposed neitherChildren()norfocusableChildren(), so every tree walk stopped at it:Entryinside the page (the page's own container ranfocusClick), but the enclosing container's focus list never contained it, and it is that container which routes every key, so typed keys went to the wrong list and were dropped.PopoverHostfinds open popovers throughChildren(), so aDropDownon a Stack page opened a popover nobody drew on top or routed clicks to.Fix.
Stackyields its visible page to both walks and itsOnEventnow runsrouteFocusKeyand click-to-focus before forwarding, asContainer/AlignBoxdo. Hidden pages are deliberately not yielded: unlike an inactiveCardLayoutcard (collapsed to an empty rect, whichgatherFocusablesskips), a hidden Stack page keeps the bounds it last had, which are the Stack's own, so a bounds check cannot exclude it. Yielding it would make Tab reach invisible widgets, put them in the accessibility tree where the visible page is, and let an open popover on a hidden page take clicks.Guard.
TestEveryContainerExposesItsChildrenonly recognisedWidgetand[]Widgetfields, which is howStackgot through. It now also treatsmap[K]Widgetas a holder (no other widget in the package holds one;ViewController.refsis not a widget).Tests (
stack_focus_test.go): typed keys reach an Entry on the visible page under a root VBox; Tab walks outside field → visible page and never into a hidden page with stale bounds, then into the new page afterSetVisible;PopoverOwnersreports the open DropDown on the visible page and nothing once it is hidden; a Stack used as the root routes focus itself;Children/focusableChildrenyield only the visible page. Plus astackcase in the existing Children tests.ListBox (#481)
Root cause.
ListBox.Draw(flat and sectioned) pushed its clip onlyif overflow, a clip meant to stop a partial trailing row bleeding past the bottom. A list that fits vertically was not clipped at all, so a row wider than the list drew past its right edge (a hostItemRenderertoo).Fix. The clip to the content rect is pushed whenever the painter is a
painter.Clipper, asEntryandSearchEntryalready do. It is the same rect as before, so the overflowing case renders the same.Test (
list_clip_test.go): pixel render on aPixelPainterwider than the list; no pixel right of the list's edge may be touched, for flat-fits, flat-overflows (control, passed before), sectioned-fits, and an ItemRenderer that paints 200 px past its rect.Verification
stack.go/list.go, new tests):TestStackEntryReceivesTypedKeys,TestStackTakesPartInTabTraversal,TestStackExposesItsVisiblePagePopover,TestStackAsRootRoutesFocus,TestEveryContainerExposesItsChildren("Stack holds Pages") and the three non-overflow cases ofTestListBoxClipsRowsWiderThanTheListfail; the overflow case passes, as expected.go vet:Childrenyielding every page fails the hidden-page assertions (Tab, popover, Children); droppingrouteFocusKey/focusClickfromStack.OnEventfailsTestStackAsRootRoutesFocus.go vet ./...,go test ./...with every function at 100.0% coverage,-raceon the touched tests.README does not describe either behaviour, so it is unchanged; the doc comments of
Stack,ListBox.DrawandfocusEnumeratorare updated.Semver
Minor.
(*Stack).Children()is new exported API (it makes*Stacksatisfy the child-walk convention). The rest is a behaviour fix.Known, not changed here: focus held by a widget on a page that
SetVisiblehides is not cleared, the same as an inactiveCardLayoutcard today.Fixes #480
Fixes #481
🤖 Generated with Claude Code