Skip to content

RichSuggestBox: close suggestion popup on unload - #899

Open
azchohfi wants to merge 4 commits into
CommunityToolkit:mainfrom
azchohfi:azchohfi-richsuggestbox-unload-popup
Open

azchohfi wants to merge 4 commits into
CommunityToolkit:mainfrom
azchohfi:azchohfi-richsuggestbox-unload-popup

Conversation

@azchohfi

@azchohfi azchohfi commented Nov 24, 2026 •

Copy link
Copy Markdown

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: 1f8e6b8a847fe4fd61023ae9e36af54d2bdb61cf

Dimension Assessment Rationale
Change confidence 9/10 ↑ Both regression rows fail on the test-only head and pass after the fix in native CI.
↑ On the current head, run 46986520722 passed every build job, including all 8 Uno jobs, with packaging green. Native ran 384 tests: 381 passed and 3 skipped.
↑ The Copilot review of the current head found no issues. It is a COMMENTED review, not a human approval.
↓ UWP ran no component tests on any head.
↓ No human review yet.
↓ The agent approved the two earlier gated fork runs with the account's admin rights. The account owner approved the current-head runs.
Diagnosis confidence 9/10 ↑ The baseline fails only at the reopen-after-completion assertion, which matches the unguarded continuation.
↑ The assertion right after unload passed, so WinUI already closes the popup when it unloads.
Evidence fit 7.5/10 ↑ Explains an unloaded, unfocused owner whose popup is open with the full list, intermittently.
↓ The reported app runs were not traced to a request pending at unload.

Fixes

No linked issue. A native-only WinUI app sometimes left an unloaded RichSuggestBox's suggestion popup open with its full list. A fresh box's popup then appeared alongside it. The app used no third-party wrapper.

PR Type

What kind of change does this PR introduce?

  • Bugfix

What is the current behavior?

RequestSuggestionsAsync awaits SuggestionRequested.InvokeAsync(...), then calls ShowSuggestionsPopup(true). It never checks whether the request is still current or whether the control is still loaded. The control also has no Unloaded handling, so a request pending at unload is never cancelled. When its deferral completes, the continuation reopens the popup on the unloaded control.

This also covers a deferral that completes just before unload. Its continuation is already queued on the dispatcher and runs after unload.

What is the new behavior?

  • On Unloaded, the control cancels the pending query's existing CancellationTokenSource and closes the popup through the existing ShowSuggestionsPopup(false) path.
  • After the awaited request returns, the popup opens only if the request's token was not cancelled. A request cancelled by unload or replaced by a newer query no longer reopens the popup.

No public API changes. No delays were added.

The new Test_RichSuggestBox_UnloadClosesSuggestionPopup test types @ through the document selection. Its SuggestionRequested handler takes a deferral, so the request stays pending until the test completes it after unload. This ordering is deterministic, with no sleeps or retries. The test has two rows:

  • Popup open, request pending. It first asserts that the popup opened for @, then types A to leave a second request pending.
  • Popup closed, request pending. The first request is pending before the popup ever opens.

Both rows assert that the popup is closed after unload and still closed after the deferral completes.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest main branch of toolkit
  • Tested code with current supported SDKs
  • New component
    • Documentation has been added
    • Sample in sample app has been added
    • Analyzers are passing for documentation and samples
    • Icon has been created (if new sample) following the Thumbnail Style Guide and templates
  • Tests for the changes have been added (if applicable)
  • Header has been added to all new source files
  • Contains NO breaking changes

Other information

The standard Windows App SDK component suite ran in the existing, unchanged CI workflow. Both runs restored Microsoft.WindowsAppSDK.WinUI 1.8.260204000.

  • Before the fix, test-only commit 3158c9e1f1e217c4c4617ab660bfa08e6a8ebe70 compiled. Both rows failed at Suggestion popup reopened after a pending request completed on an unloaded control. The assertion right after unload passed, so WinUI closes the popup on unload and the pending continuation reopens it. The full suite finished with 384 total, 379 passed, 2 failed and 3 skipped. Native baseline job.
  • After the fix, on commit d7dfbc92021c1feed1d35719ba186d61f56d444d, both unchanged rows passed. The full suite finished with 384 total, 381 passed and 3 skipped. After-fix native job.

Both UWP jobs built and passed the 39 source-generator tests (baseline, after fix). Both reported No test is available in entrypoint\CommunityToolkit.Tests.Uwp.exe for component tests, so they show only that the code builds.

Eight Uno-target jobs failed in Run Uno Check to Install Dependencies, before compiling. That is the shared CI issue fixed by #893.

Main was merged into this branch twice without rewriting history. The first merge brought in #893 (af067edcc29e92cb28376aaf54f4cd99c8ac523f), and the second brought in later main through a43f66a. Neither merge changed the RichSuggestBox diff.

On the current head 1f8e6b8a847fe4fd61023ae9e36af54d2bdb61cf, run 46986520722 passed all 17 build jobs and both package jobs. That includes all 8 Uno jobs, which now get past Run Uno Check to Install Dependencies. The native job passed both regression rows, with 384 total, 381 passed and 3 skipped. UWP again built but reported No test is available. Run 45710245897 on the earlier head 21d2800c52f1636fd73b9b82376e50804434ec7d had the same results. The native before/after results above belong to the commits named there.

The Copilot review of 1f8e6b8a847fe4fd61023ae9e36af54d2bdb61cf completed with no open issues or inline comments. Its state is COMMENTED, not a human approval.

Both earlier fork workflow runs (45497230771 and 45499992386) were waiting for approval. The agent approved them with the account's admin rights, not a maintainer. The account owner, azchohfi, approved the later runs 45710245897 and 46986520722.

All current-head checks pass, and the PR is ready for review. No merge or auto-merge is requested. No CI workflow was changed. No local GUI, Appx or OS operations were used.

azchohfi and others added 2 commits November 24, 2026 22:03
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Cancel the pending suggestion request and close the popup when the
control unloads, and do not reopen the popup from a request that was
superseded or cancelled while awaiting SuggestionRequested.

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
…-unload-popup

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI 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.

🟢 Approval recommended

No active review issues were identified for the change preventing pending suggestion requests from reopening the popup after unload.

No open issues 🎉

What changed in this PR

Prevents pending suggestion requests from reopening a RichSuggestBox popup after the control unloads, without changing the public API.

Changes:

  • Cancels the current query and closes the suggestion popup on unload.
  • Checks cancellation before showing suggestions after an asynchronous request completes.
  • Adds regression tests for unloading with a pending request while the popup is either open or closed.
File Description
components/​RichSuggestBox/​tests/​Test_RichSuggestBox.cs Adds two deferred-request regression cases covering popup state after unload and request completion.
components/​RichSuggestBox/​src/​RichSuggestBox.Suggestion.cs Prevents cancelled requests from reopening the popup.
components/​RichSuggestBox/​src/​RichSuggestBox.cs Registers unload handling to cancel the current query and close the popup.

Review effort: Balanced

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

Copilot AI 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.

🟢 Approval recommended

No active review issues are reported for the change addressing RichSuggestBox’s popup reopening after unload.

No open issues 🎉

Review effort: Balanced

@azchohfi
azchohfi marked this pull request as ready for review December 2, 2026 23:48

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants