bevyengine/bevy · warning · TabNavigationError
No tab group found for currently focused entity {previous_fo
Error message
No tab group found for currently focused entity {previous_focus}. Users will not be able to navigate back to this entity. What it means
navigate was called while the focused entity has no TabGroup ancestor. Navigation still computed where focus should go, but the error is returned because from the new focus the user will not be able to tab back to the previous one. The payload carries previous_focus and new_focus precisely so callers can recover by setting InputFocus to new_focus (tab_navigation.rs:245-256).
Source
Thrown at crates/bevy_input_focus/src/tab_navigation.rs:145
Last,
}
/// An error that can occur during [tab navigation](crate::tab_navigation).
#[derive(Debug, Error, PartialEq, Eq, Clone)]
pub enum TabNavigationError {
/// No tab groups were found.
#[error("No tab groups found")]
NoTabGroups,
/// No focusable entities were found.
#[error("No focusable entities found")]
NoFocusableEntities,
/// Could not navigate to the next focusable entity.
///
/// This can occur if your tab groups are malformed.
#[error("Failed to navigate to next focusable entity")]
FailedToNavigateToNextFocusableEntity,
/// No tab group for the current focus entity was found.
#[error("No tab group found for currently focused entity {previous_focus}. Users will not be able to navigate back to this entity.")]
NoTabGroupForCurrentFocus {
/// The entity that was previously focused,
/// and is missing its tab group.
previous_focus: Entity,
/// The new entity that will be focused.
///
/// If you want to recover from this error, set [`InputFocus`] to this entity.
new_focus: Entity,
},
}
/// An injectable helper object that provides tab navigation functionality.
#[doc(hidden)]
#[derive(SystemParam)]
pub struct TabNavigation<'w, 's> {
// Query for tab groups.
tabgroup_query: Query<'w, 's, (Entity, &'static TabGroup, &'static Children)>,
// Query for tab indices.View on GitHub (pinned to 396ca72708)
Solutions
- Recover from the error: set InputFocus to the new_focus field, e.g. input_focus.set(new_focus, FocusCause::Navigated).
- Add a TabGroup to an ancestor of any entity that can hold focus.
- Before focusing an entity directly, verify it participates in a tab group.
Example fix
// before: focus on entity outside any TabGroup, then Tab -> error, focus not moved
// after: recover using the error payload
match tab_nav.navigate(&input_focus, NavAction::Next) {
Err(TabNavigationError::NoTabGroupForCurrentFocus { new_focus, .. }) => {
input_focus.set(new_focus, FocusCause::Navigated);
}
Ok(next) => {
input_focus.set(next, FocusCause::Navigated);
}
Err(err) => warn!("{err}"),
} Defensive patterns
Strategy: try-catch
Validate before calling
use bevy_ecs::prelude::*;
use bevy_input_focus::tab_navigation::{TabGroup, TabIndex};;
fn focus_in_tab_group(
focus: Entity,
parents: &Query<&ChildOf>,
groups: &Query<(), &TabGroup>,
) -> bool {
parents.iter_ancestors(focus).any(|a| groups.contains(a))
} Try / catch
match tab_nav.navigate(&input_focus, NavAction::Next) {
Err(TabNavigationError::NoTabGroupForCurrentFocus { new_focus, .. }) => {
// documented recovery: adopt the computed target
input_focus.set(new_focus, FocusCause::Navigated);
}
Ok(next) => { input_focus.set(next, FocusCause::Navigated); }
Err(e) => warn!("{e}"),
} Prevention
- Ensure anything that can hold focus descends from a TabGroup.
- When removing a TabGroup, clear focus on its descendants in the same change.
- Validate focus targets before setting focus programmatically.
When it happens
Trigger: Focusing an entity outside any TabGroup tree (e.g. direct mouse focus on a decorative element) and then pressing Tab; removing a TabGroup ancestor while one of its descendants holds focus.
Common situations: Mixing mouse-driven focus with keyboard tab navigation; UI refactor removed a TabGroup while its child was focused; programmatically focused overlay elements that never joined the tab order.
Related errors
- No tab groups found
- No focusable entities found
- Failed to navigate to next focusable entity
- No focusable entity is currently set.
- No neighbor from {current_focus} in the {direction:?} direct
AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20).
Data as JSON: /api/errors/6bdb2735b1daafac.
Report an issue: GitHub.