Skip to content

Inconsistent handling of focus in bevy_ui_widgets #25072

Description

@viridia

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-UIGraphical user interfaces, styles, layouts, and widgetsC-Code-QualityA section of code that is hard to understand or changeC-FeatureA new feature, making something new possibleD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!X-UncontroversialThis work is generally agreed upon

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Needs SME Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions