Skip to content

Fixed overlay popups not automatically closing #16564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

TomEdwardsEnscape
Copy link
Contributor

Fixes #16559. The issue was introduced by #15596.

What is the current behavior?

Because overlay popups are hosted within the current window, the code which detects whether the pointer is over the current tooltip produces a false positive.

Breaking changes

None

Obsoletions / Deprecations

None

@TomEdwardsEnscape
Copy link
Contributor Author

We have an entire test class (ToolTipTests_Overlay) which covers overlay popups. I'm not yet sure why these tests have been passing with such a critical bug in the code.

@MrJul MrJul added bug backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch labels Aug 1, 2024
@MrJul
Copy link
Member

MrJul commented Aug 1, 2024

We have an entire test class (ToolTipTests_Overlay) which covers overlay popups. I'm not yet sure why these tests have been passing with such a critical bug in the code.

Indeed! The change looks good, but a matching test (or fix for existing test) would be appreciated, to ensure we don't regress this again.

Verify popup type whenever we verify that the popup is open
@TomEdwardsEnscape
Copy link
Contributor Author

TomEdwardsEnscape commented Aug 3, 2024

The way in which popups are created changed, so the tests were stuck on default behaviour (tooltip in a popup). I fixed this and added verification that the tooltip host is of the expected type to prevent future issues.

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0050899-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul
Copy link
Member

MrJul commented Aug 3, 2024

The way in which popups are created changed, so the tests were stuck on default behaviour (tooltip in a popup). I fixed this and added verification that the tooltip host is of the expected type to prevent future issues.

Thanks.

While I understand the changes and can see that the overlay host is correctly being used, no tests are actually failing if I revert the actual fix in ToolTipService while using the new tests, which is a bit perplexing...

(Also I don't know why we weren't using the already correctly configured mock IWindowPlatform previously instead of calling the static MockWindowingPlatform.CreateWindowMock directly and needing the new workaround - but that's another issue.)

@TomEdwardsEnscape
Copy link
Contributor Author

Excellent point. This secondary issue was caused by overlay tooltips not ever being attached to the visual tree in tests: the layout of the overlay layer is only calculated during rendering, which doesn't happen in headless unit tests. The layer is now manually measured by the overlay test class whenever a tooltip opens, plus we ensure that expected values have been assigned.

I wasn't able to get the configured mock windowing platform object to be used, even if I used AvaloniaLocator to request the interface. Not sure why, but the current solution offers a stronger guarantee of correctness than any "clean" approach would so I'm happy with it.

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0050919-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul added this pull request to the merge queue Aug 3, 2024
@MrJul
Copy link
Member

MrJul commented Aug 3, 2024

Excellent point. This secondary issue was caused by overlay tooltips not ever being attached to the visual tree in tests: the layout of the overlay layer is only calculated during rendering, which doesn't happen in headless unit tests. The layer is now manually measured by the overlay test class whenever a tooltip opens, plus we ensure that expected values have been assigned.

That makes perfect sense. Thank you for the fix.

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 3, 2024
@maxkatz6 maxkatz6 merged commit d1cdb29 into AvaloniaUI:master Aug 4, 2024
10 checks passed
@TomEdwardsEnscape TomEdwardsEnscape deleted the fixes/overlay-popups-not-closing branch August 4, 2024 11:43
@maxkatz6 maxkatz6 added customer-priority Issue reported by a customer with a support agreement. backported-11.1.x and removed backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch labels Aug 12, 2024
maxkatz6 pushed a commit that referenced this pull request Aug 12, 2024
* Fixed overlay popups not automatically closing

* Fix overlay tooltip tests not actually generating overlay tooltips
Verify popup type whenever we verify that the popup is open

* Fixed overlay tooltips not being attached to the visual tree in tests
#Conflicts:
#	tests/Avalonia.Controls.UnitTests/ToolTipTests.cs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported-11.1.x bug customer-priority Issue reported by a customer with a support agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The ToolTip Popup not close when pointer exit the control,Is that a feature or bug?
4 participants