-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Inconsistent handling of focus in bevy_ui_widgets #25072
Copy link
Copy link
Open
Labels
A-UIGraphical user interfaces, styles, layouts, and widgetsGraphical user interfaces, styles, layouts, and widgetsC-Code-QualityA section of code that is hard to understand or changeA section of code that is hard to understand or changeC-FeatureA new feature, making something new possibleA new feature, making something new possibleD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!This issue is ready for an implementation PR. Go for it!X-UncontroversialThis work is generally agreed uponThis work is generally agreed upon
Description
Metadata
Metadata
Assignees
Labels
A-UIGraphical user interfaces, styles, layouts, and widgetsGraphical user interfaces, styles, layouts, and widgetsC-Code-QualityA section of code that is hard to understand or changeA section of code that is hard to understand or changeC-FeatureA new feature, making something new possibleA new feature, making something new possibleD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!This issue is ready for an implementation PR. Go for it!X-UncontroversialThis work is generally agreed uponThis work is generally agreed upon
Type
Fields
No fields configured for issues without a type.
Projects
StatusShow more project fields
Needs SME Triage
What problem does this solve or what need does it fill?
Some of the widgets in
bevy_ui_widgets(like checkbox) set focus to themselves when clicked; others (like button) do not.Doing this is redundant, since we already have a global observer that does this for all focusable entities.
What solution would you like?
The code to set focus should be removed, since it's redundant and confusing. More generally, widgets should not manipulate focus at all if we can help it, widgets should only be consumers of focus. Instead, the setting and clearing of focus should be handled globally and consistently.
Additional context
Note that this is orthogonal to the debate about how focus interacts with disabled widgets; the global click-to-focus handler is able to make this decision without help from the widgets.
However, this relies on the click-to-focus handler being installed (which I think it will be, based on the current feature flag / default plugin installations).
@alice-i-cecile @gagnus