Skip to content

Windows: fix for popup descendent of popup closing the whole tree when the 2nd popup gains focus - #196911

Merged
robert-ancell merged 3 commits into
flutter:masterfrom
canonical:fix-windows-nested-popup-focus
Nov 27, 2026
Merged

robert-ancell merged 3 commits into
flutter:masterfrom
canonical:fix-windows-nested-popup-focus

Conversation

@mattkae

@mattkae mattkae commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What's new?

This fixes a windows bug where a popup tree would erroneously close when a popup of a popup was focused.

fixes #193782

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant in-code documentation (doc comments with ///).
  • If this PR introduces a new feature or capability, I created and linked a website documentation issue or PR in [flutter/website] (or verified none is needed).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions Bot added the framework flutter/packages/flutter repository. See also f: labels. label Nov 18, 2026
@mattkae
mattkae force-pushed the fix-windows-nested-popup-focus branch 2 times, most recently from 5e9c7f5 to af4af7d Compare November 19, 2026 13:23
@mattkae mattkae added the CICD Run CI/CD label Nov 19, 2026
@mattkae
mattkae force-pushed the fix-windows-nested-popup-focus branch from af4af7d to 8d53db3 Compare November 19, 2026 13:25
@mattkae
mattkae marked this pull request as ready for review November 19, 2026 13:25

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support and integration tests for nested popups on Windows, ensuring that activating a nested popup does not close its parent. It updates the Win32 window activation logic to use lParam deterministically and introduces a helper to check window ownership. Feedback highlights two critical issues: a potential crash on 32-bit Windows due to signed lParam addresses passed to ffi.Pointer.fromAddress, and a bug in the window hierarchy traversal of isSelfOrDescendant when child windows gain focus, which can be resolved by using GetParent instead of GetWindow and IsChild.

@mattkae
mattkae force-pushed the fix-windows-nested-popup-focus branch from c2a58a2 to bf007ad Compare November 24, 2026 16:36

@robert-ancell robert-ancell left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@robert-ancell
robert-ancell added this pull request to the merge queue Nov 27, 2026
Merged via the queue into flutter:master with commit 43150a8 Nov 27, 2026
19 checks passed
@robert-ancell
robert-ancell deleted the fix-windows-nested-popup-focus branch November 27, 2026 04:22
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 27, 2026
flutter/flutter@82ec424...43150a8

2026-11-27 [email protected] Windows: fix for popup descendent of popup closing the whole tree when the 2nd popup gains focus (flutter/flutter#196911)
2026-11-27 [email protected] Roll Skia from d693d85a4b77 to fe34f20b9689 (1 revision) (flutter/flutter#197491)
2026-11-27 [email protected] Roll Dart SDK from 691817e0ec3b to 5c3e102fc422 (1 revision) (flutter/flutter#197489)
2026-11-27 [email protected] Roll Fuchsia Linux SDK from 0bgCrr76CM4IqPO0v... to cBAjguERWwvY6tFtz... (flutter/flutter#197488)
2026-11-27 [email protected] [flutter_tools] Delete AppContext and legacy test context shims (flutter/flutter#197412)
2026-11-26 [email protected] Revert: [tool][engine] Enable experimental VM service by default (flutter/flutter#197481)
2026-11-26 [email protected] iOS: Remove engine includes from the platform views controller headers (flutter/flutter#197429)
2026-11-26 [email protected] [tool][engine] Enable experimental VM service by default (flutter/flutter#190100)
2026-11-26 [email protected] Add trust gate flags for "flutter analyze" (flutter/flutter#196415)
2026-11-26 [email protected] Roll Dart SDK from 7fcaf46b0308 to 691817e0ec3b (1 revision) (flutter/flutter#197475)
2026-11-26 [email protected] [Windows] Fix MASM flags in Windows GN `tool("asm")` (flutter/flutter#197464)
2026-11-26 [email protected] Roll Skia from cef5963c1bb2 to d693d85a4b77 (2 revisions) (flutter/flutter#197469)
2026-11-26 [email protected] Roll Packages from 105a874 to da586f5 (3 revisions) (flutter/flutter#197471)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
}
},
timeout: Timeout.none,
// TODO(mattkae): Enable on other platforms once nested popup activation is supported there.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This TODO is causing analysis failures since skip requires comments that match [intended] <reason>. The lint wasn't being run properly before and was fixed by f0038a3 after the presubmits had already succeeded on this PR.

FYI @jtmcdole @eyebrowsoffire, here's another instance where making Tree Analyze blocking on the merge queue would have prevented the tree from breaking.

@bkonyi

bkonyi commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Reason for revert: failing analysis checks.

@bkonyi bkonyi added the revert Autorevert PR (with "Reason for revert:" comment) label Nov 27, 2026
@flutteractionsbot

Copy link
Copy Markdown
Contributor

Successfully created revert PR: #197530

@flutteractionsbot flutteractionsbot removed the revert Autorevert PR (with "Reason for revert:" comment) label Nov 27, 2026
bkonyi pushed a commit to bkonyi/flutter that referenced this pull request Nov 27, 2026
…tree when the 2nd popup gains focus (flutter#197530)

Reverts: [Windows: fix for popup descendent of popup closing the whole
tree when the 2nd popup gains
focus](flutter#196911)

Initiated by: @bkonyi

Reason for reverting: failing analysis checks.

Original PR Author: @mattkae

Reviewed By: @robert-ancell

The original PR description is provided below:

## What's new?
This fixes a windows bug where a popup tree would erroneously close when
a popup of a popup was focused.

fixes flutter#193782

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Windows] Focusing a nested popup closes both popups and sends the main window behind other applications

4 participants