bevy/crates/bevy_input_focus/src
Alice Cecile 5f1e762f19
Return Result from tab navigation API (#17071)
# Objective

Tab navigation can fail in all manner of ways. The current API
recognizes this, but merely logs a warning and returns `None`.

We should supply the actual reason for failure to the caller, so they
can handle it in whatever fashion they please (including logging a
warning!).

Swapping to a Result-oriented pattern is also a bit more idiomatic and
makes the code's control flow easier to follow.

## Solution

- Refactor the `tab_navigation` module to return a `Result` rather than
an `Option` from its key APIs.
- Move the logging to the provided prebuilt observer. This leaves the
default behavior largely unchanged, but allows for better user control.
- Make the case where no tab group was found for the currently focused
entity an error branch, but provide enough information that we can still
recover from it.

## Testing

The `tab_navigation` example continues to function as intended.
2025-01-01 04:05:48 +00:00
..
autofocus.rs Remove SetInputFocus helper trait (#16888) 2024-12-19 00:40:10 +00:00
lib.rs Make the input focus docs less keyboard-centric (#17069) 2024-12-31 18:37:48 +00:00
tab_navigation.rs Return Result from tab navigation API (#17071) 2025-01-01 04:05:48 +00:00