fix(context_menu): fix issue with overlay buttons always being disabled (issue #378)#415
Merged
genusistimelord merged 1 commit intoMar 19, 2026
Conversation
While context menu overlay was visible, it kept recreating overlay widgets from a closure. Button stores visual state on the widget itself, so rebuilding the overlay caused buttons to incorrectly render as disabled. This was fixed by rebuilding overlay widgets only when context menu becomes visible and caching them. This allows us to reuse the cached overlay widgets while the context menu is open. The old context_menu snapshot has been updated because it incorrectly showed disabled buttons. All context_menu tests now pass.
rokcej
commented
Mar 19, 2026
rokcej
commented
Mar 19, 2026
genusistimelord
approved these changes
Mar 19, 2026
genusistimelord
left a comment
Collaborator
There was a problem hiding this comment.
Everything looks good code wise and makes sense. Just need to get it to pass the marks then it can be merged.
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.
Issue
Buttons inside a context menu overlay always show up as disabled. This happens because context menu keeps recreating overlay widgets from a closure.
Buttonstores visual state on the widget itself, so rebuilding the overlay each time prevents button status from correctly updating ==> buttons always get rendered as disabled.This also fixes issue #378.
Reproduction steps
examples/context_menu.rs.Solution
The fix is to rebuild overlay widgets only when context menu becomes visible and cache them (
overlay_instance). This allows us to reuse the cached overlay widgets and preserve their internal state while the context menu is open.If you have any questions or see potential concerns, let's discuss them.
The old
context_menusnapshot (tests/snapshots/context_menu_with_multiple_buttons_in_overlay-wgpu.png) has been updated because it incorrectly showed disabled buttons. Allcontext_menutests now pass.