Skip to content

fix(agent): a widget under an IndexedStack child that is not shown is not visible, in Flutter 3.44 and 3.50 (#900) - #901

Merged
pbertsch merged 1 commit into
mainfrom
fix/indexed-stack-hidden-children
Nov 18, 2026
Merged

pbertsch merged 1 commit into
mainfrom
fix/indexed-stack-hidden-children

Conversation

@pbertsch

Copy link
Copy Markdown
Member

Summary

Fixes #900. On Flutter 3.50.0 the agent treated the children of an IndexedStack that are not shown, and the items of a closed DropdownButton (which keeps them in an IndexedStack), as visible: see passed and don't see failed. Flutter 3.44.8 wrapped each hidden child in a Visibility(visible: false), the one thing the agent recognised; 3.50.0 does not. In both versions RenderIndexedStack paints and hit-tests only the child at its index, and the hidden child stays mounted, laid out and attached.

The agent now reads the stack's index, so the fix does not depend on a wrapper:

  • probeIndexedStackShown / probeIsShownChild (probe_agent/lib/src/finder.dart): for the element of an IndexedStack (a MultiChildRenderObjectElement whose render object is a RenderIndexedStack), the position of the shown child; -1 for a null index or an index out of range.
  • The tree walk (_visitElement) descends only into the shown child; the ancestor check (_isVisible) refuses a widget under another child; the device view's node list (collectProbeNodes) lists only the shown child. All three use the same helper.
  • An ordinary Stack is untouched. Nested stacks count each level. A child that is shown again is found again, with its state (the stack keeps it mounted).
  • Not changed: Offstage and Visibility rules (a password field under a hidden child is no longer a field on screen for hasSecretField, the same as under an Offstage).

Tests and measurement

probe_agent/test/indexed_stack_hidden_test.dart (10 widget tests, no device), run with the Flutter 3.44.8 and the 3.50.0 SDKs, each with its own pub cache and home:

Flutter 3.44.8 Flutter 3.50.0
before the change 10 of 10 pass 9 of 10 fail (the tenth is the ordinary Stack control)
after the change 10 of 10 pass 10 of 10 pass

The whole probe_agent suite passes on 3.44.8 (345 passed, 2 skipped). On 3.50.0 it ran from a scratch copy of the package: 344 passed, 2 skipped, and one test that reads ../internal/textfold/testdata/cases.json failed only because the copy has no such folder (it passes in the repository on 3.44.8).

Cases: the issue's screen (shown and hidden page, closed dropdown); tap on a hidden button (error, no tap); an index change, a tap on the page now shown, and the page shown again with its count; an index of null; nested stacks (the inner one shows its second child; an inner stack under a hidden child); an ordinary Stack; a closed dropdown with a hint and one with a value, then the open menu; the visible summary and the device view; a password field under a hidden child.

Mutants, each applied alone to the new code and run on 3.50.0: a null index shown as child 0, the walk's position counter, the RenderIndexedStack type check, the walk's filter (killed by the password-field test, since hasSecretField has no later visibility check), the device view's filter: all killed. Not killed, and equivalent today: dropping the ancestor rule in _isVisible, not advancing below, and position <= shown in probeIsShownChild. Every caller of _isVisible reaches its elements through the tree walk, which already skips the hidden children, so that rule only matters for a caller that builds its own element list; it is kept next to the Offstage and Visibility rules for that case, and nothing tests it directly.

Docs

  • docs/compat/MATRIX.md: a measured finding (Flutter versions, what was and was not measured). The Pickers and menus row stays "not assessed" (no fixture screen or device test), so no cell changed and the NEXT.md count stays 10.
  • website/src/content/docs/tools/agent.md: the visibility rule names the IndexedStack and the closed DropdownButton.
  • CHANGELOG.md (Fixed, last) and probe_agent/CHANGELOG.md.

Not measured

  • An app with tab pages in an IndexedStack, on a device or in a widget test: only the screens of the tests above.
  • tap on a hidden child on a device, and any run on a device. No fixture screen was added (the family has none).
  • Flutter versions between 3.19 (the package's floor) and 3.44, and after 3.50.0: RenderIndexedStack.index is public in 3.44.8 and 3.50.0; older versions were not run.
  • Other widgets that hide children without an Offstage or Visibility widget.
  • An app that keeps an older agent: it keeps the old answer on Flutter 3.50 until it takes this agent.

Test plan

  • flutter test test/indexed_stack_hidden_test.dart on Flutter 3.44.8 and 3.50.0 (10 of 10 each)
  • the same file against the previous finder.dart and device_view.dart: 9 of 10 fail on 3.50.0
  • flutter test for the whole package on Flutter 3.44.8
  • flutter analyze on the changed files
  • go test ./scripts/ and node website/scripts/check-truth.mjs
  • independent review at the head

@pbertsch
pbertsch requested a review from a team as a code owner November 18, 2026 18:46
@pbertsch pbertsch changed the title fix(agent): a widget under an IndexedStack child that is not shown is not visible, in every Flutter version (#900) fix(agent): a widget under an IndexedStack child that is not shown is not visible, in Flutter 3.44 and 3.50 (#900) Nov 18, 2026
@pbertsch
pbertsch merged commit 2fb46d9 into main Nov 18, 2026
12 checks passed
pbertsch added a commit that referenced this pull request Nov 18, 2026
…ow; follow-up tests and notes for #899 and #901 (#902)

## Summary

The nits of the reviews of #899 and #901, in one small pull request (a site-check test and README change, and an agent change).

**Agent (follow-up to #901):**

- A bare `scroll down` (no selector) could still move a list on a page an `IndexedStack` does not show. It ranks scrollables by "can be scrolled", then "receives touches", then size; when the shown page's list was too short to scroll, a long list on a page that is not shown ranked higher and was moved, so nothing changed on screen and the step passed. The walk in `_findScrollable` now skips the pages the stack does not show (`probeIndexedStackShown`, the helper of #901).
- Tests: `probe_agent/test/indexed_stack_bare_scroll_test.dart` (4 widget tests: the hidden page before and after the shown one, an index of `null`, and a control), run on Flutter 3.44.8 and 3.50.0. Against the previous `executor.dart`, 3 of the 4 fail on both versions (the control passes); with the change all pass.
- Test for the surviving mutant of #901 (`position <= shown` in the tree walk): a password field on a page before and after the shown one (`hasSecretField`, pages 0 to 2). The five position mutants (`<=` and `>=` in the walk and in the scroll walk, and the filter dropped in the scroll walk) are killed on Flutter 3.50.0.
- The negative index is documented in `docs/compat/MATRIX.md`: the agent reads it as "shows nothing"; a raw `RenderIndexedStack` with index -1 paints its first child, but `IndexedStack` asserts the index is null or in range in debug builds of both versions (checked in both SDK sources), so only a release build can reach it, and that was not run.
- The matrix also lists what stays on a bare child walk and why: the recorder tracks every mounted text field, hidden pages included, so a password field on a page that is not shown is still masked; the element dump, the screenshot boundary and the walks that start below an element already found do not read the stack's index and were not measured with a hidden page. An `IndexedStack` matrix row waits for a device run.

**Website truth check (follow-up to #899):**

- Tests for each end of the dash range (U+2010 to U+2015), a plain-space "money back" and the one-word "moneyback", as offers (must fail) and as denials (must pass). The text of #899 said each end of the range was mutated and killed; for these ends it was not true. Now every end of the range (start, end, the space, the ASCII hyphen, "hyphen required") is mutated in the offer loop and the denial pattern, and all are killed; the one survivor of that round ("hyphen required" in the denial pattern) got the "moneyback" denial case. Each promise word is mutated too (promptly, anytime, any time, guaranteeing, instantly, automatically, immediately, granted): all killed.
- `website/README.md` lists every promise word (it missed "automatically", "promptly", "immediately", "any time", "anytime") and says that a neighbouring sentence with one of them ("Cancel any time.", "Plans renew automatically.", "Access is granted to every member.") fails and must be reworded; three must-fail tests pin those known false rejections.

## Tests

- Agent, whole `probe_agent` suite: Flutter 3.44.8 350 passed, 2 skipped. Flutter 3.50.0 from a scratch copy of the package: 349 passed, 2 skipped, and one test that reads `../internal/textfold/testdata/cases.json` failed only because the copy has no such folder.
- `flutter analyze` on the changed files: clean.
- `go test -count=1 ./scripts/`, `staticcheck ./scripts/`, `GOOS=windows go vet ./scripts/` and `node website/scripts/check-truth.mjs` (7 files match).

## Docs

`docs/compat/MATRIX.md` (the IndexedStack finding), `CHANGELOG.md` (Changed and Fixed, last in each), `probe_agent/CHANGELOG.md`, `website/README.md`.

## Not measured

- An app with tab pages in an `IndexedStack`; a device run; `tap` on a hidden child on a device.
- The screenshot boundary, the element dump and the other bare walks of `executor.dart` with a hidden page.
- A release build with a negative index.
- Flutter versions other than 3.44.8 and 3.50.0.

## Test plan

- [x] new agent tests on Flutter 3.44.8 and 3.50.0; before/after for the scroll tests
- [x] whole `probe_agent` suite on 3.44.8 (and on 3.50.0 from a copy)
- [x] site tests, staticcheck, Windows vet, truth check
- [ ] independent review at the head
pbertsch added a commit that referenced this pull request Nov 18, 2026
… is asserted again (fixed in #901), and the fixture test is a regression test
pbertsch added a commit that referenced this pull request Nov 18, 2026
… on Flutter 3.44.8 and 3.50.0 (draft) (#903)

## Summary

Pickers and menus, first two widgets: `DropdownButton` and `PopupMenuButton`, assessed on Flutter 3.44.8 and Flutter 3.50.0. This is a **draft** so that it is reviewed before it is merged.

- **A `pickers` screen** in the Flutter fixture app (`PROBE_FIXTURE_WIDGETS=pickers`): a `DropdownButton` with a hint, a disabled one with the id on the control and one with the id on a wrapper only; three `PopupMenuButton`s (a text child, the default icon with a tooltip, a disabled one). Every state a test checks is also shown as text, and `Item taps` counts every tap on a dropdown item.
- **A suite** (`probe-tests/widgets/pickers.probe`, 17 tests) and **12 negative variants** (`probe-tests/negative/pickers.probe.expect-fail`, each with its expected message; three are known gaps, a correct step that fails today: issue #864).
- **A finding that is fixed:** found on Flutter 3.50.0 with the agent of `main` at `15fba797` (issue #900), the items of a closed `DropdownButton` were seen (a `DropdownButton` keeps them in an `IndexedStack`). It is fixed by #901 (squash `2fb46d90`). The suite asserts it again, as its first test, and gets the same result on both versions. `native-test-apps/flutter/test/pickers_indexed_stack_regression_test.dart` runs the same check on the pickers screen and on a plain `IndexedStack` (by hand, once with each Flutter; no device; CI does not run it). It is a different file from the agent's own `probe_agent/test/indexed_stack_hidden_test.dart`.
- **Matrix:** the Pickers and menus row (find, tap and read "see below" for the two widgets, `fixture` and `device test` set; `type` and `scroll` stay "not assessed"), a new section, a run paragraph, and the sentence from #901 that said the row stays "not assessed" is brought up to date. `NEXT.md` item 2 is "half done". The count of "not assessed" cells goes from 10 on `main` to 5, recounted from the family table with a script that reads the exact cell text. CHANGELOG, last bullet of Added.

## Results (Android emulator `ProbeWebViewSpike`, Android 15, API 35)

Builds with the agent of `main` at `2fb46d90` (the fix of #900). The agent change of #902 (a bare `scroll` skips pages an `IndexedStack` does not show) landed after these runs and was not in the builds; the suite uses no bare `scroll`, so it does not exercise it.

| | Flutter 3.44.8 | Flutter 3.50.0 |
|---|---|---|
| `pickers.probe` | 17 of 17 passed | 17 of 17 passed |
| negative file | 0 passed, 12 failed | 0 passed, 12 failed |

Every negative failed at its own step with the message in its comment, on both builds. 58 `restart the app` steps (29 per build), none failed in `before each test` (issue #823's rate, about 1 in 25, predicts about 2; one suite at a time on a no-window emulator, load not measured, so this does not show the failure is gone).

An earlier version of the suite (16 tests, 11 negatives, no assertion about the closed dropdown's items) was run with the agent at `15fba797`, before the fix: 16 of 16 and 11 of 11 on both builds. That run found issue #900; it is not the current result.

**Findings** (in the matrix): a tap on a widget under an open menu lands on the barrier (the menu closes, the widget is not pressed); a tap on the name of the chosen value in the open menu reaches the menu item, not the button under it; `tap` by tooltip and by id open a popup menu; a disabled dropdown and a disabled popup menu open nothing; `is disabled` does not read them (#864); `see #id contains` reads "" for them.

## Checked

- Both Flutter versions were run for real, as above (the 3.50.0 build in a scratch copy with a private SDK).
- `pickers_indexed_stack_regression_test.dart` passes on both versions with the fixed agent; with the agent before the fix it failed on 3.50.0 (run once, before the rework of the test).
- The family file was merged with `main` by taking `main`'s version and re-adding the Pickers class and its two registry lines; it analyzes cleanly and is formatted.
- A clean clone of the branch passes `go test ./scripts/`; `make ci-local` and the disclosure scan: see the head.

## Not checked / limits

- Android only; iOS, a physical device and other API levels were not run. `DatePickerDialog`, `showTimePicker`, `CupertinoPicker`, `DropdownMenu`, `MenuAnchor`, long popup menus, keyboard navigation and type-ahead are not covered (listed in the matrix).
- No test on an app with an `IndexedStack` of tab pages was made on a device.

## Docs

The matrix, `NEXT.md` and the CHANGELOG are updated here; the website and the wiki do not describe this fixture family, so they do not change.

## Test plan

- [x] device runs above (both Flutter versions), negative file
- [x] regression test on both versions
- [x] `make ci-local`, disclosure scan clean
- [ ] Review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant