{"record":{"id":"6bdb2735b1daafac","repo":"bevyengine/bevy","slug":"no-tab-group-found-for-currently-focused-entity-p","errorCode":null,"errorMessage":"No tab group found for currently focused entity {previous_focus}. Users will not be able to navigate back to this entity.","messagePattern":"No tab group found for currently focused entity (.+?)\\. Users will not be able to navigate back to this entity\\.","errorType":"exception","errorClass":"TabNavigationError","httpStatus":null,"severity":"warning","filePath":"crates/bevy_input_focus/src/tab_navigation.rs","lineNumber":145,"sourceCode":"    Last,\n}\n\n/// An error that can occur during [tab navigation](crate::tab_navigation).\n#[derive(Debug, Error, PartialEq, Eq, Clone)]\npub enum TabNavigationError {\n    /// No tab groups were found.\n    #[error(\"No tab groups found\")]\n    NoTabGroups,\n    /// No focusable entities were found.\n    #[error(\"No focusable entities found\")]\n    NoFocusableEntities,\n    /// Could not navigate to the next focusable entity.\n    ///\n    /// This can occur if your tab groups are malformed.\n    #[error(\"Failed to navigate to next focusable entity\")]\n    FailedToNavigateToNextFocusableEntity,\n    /// No tab group for the current focus entity was found.\n    #[error(\"No tab group found for currently focused entity {previous_focus}. Users will not be able to navigate back to this entity.\")]\n    NoTabGroupForCurrentFocus {\n        /// The entity that was previously focused,\n        /// and is missing its tab group.\n        previous_focus: Entity,\n        /// The new entity that will be focused.\n        ///\n        /// If you want to recover from this error, set [`InputFocus`] to this entity.\n        new_focus: Entity,\n    },\n}\n\n/// An injectable helper object that provides tab navigation functionality.\n#[doc(hidden)]\n#[derive(SystemParam)]\npub struct TabNavigation<'w, 's> {\n    // Query for tab groups.\n    tabgroup_query: Query<'w, 's, (Entity, &'static TabGroup, &'static Children)>,\n    // Query for tab indices.","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_input_focus/src/tab_navigation.rs#L127-L163","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: focus on entity outside any TabGroup, then Tab -> error, focus not moved\n\n// after: recover using the error payload\nmatch tab_nav.navigate(&input_focus, NavAction::Next) {\n    Err(TabNavigationError::NoTabGroupForCurrentFocus { new_focus, .. }) => {\n        input_focus.set(new_focus, FocusCause::Navigated);\n    }\n    Ok(next) => {\n        input_focus.set(next, FocusCause::Navigated);\n    }\n    Err(err) => warn!(\"{err}\"),\n}","handlingStrategy":"try-catch","validationCode":"use bevy_ecs::prelude::*;\nuse bevy_input_focus::tab_navigation::{TabGroup, TabIndex};;\n\nfn focus_in_tab_group(\n    focus: Entity,\n    parents: &Query<&ChildOf>,\n    groups: &Query<(), &TabGroup>,\n) -> bool {\n    parents.iter_ancestors(focus).any(|a| groups.contains(a))\n}","typeGuard":null,"tryCatchPattern":"match tab_nav.navigate(&input_focus, NavAction::Next) {\n    Err(TabNavigationError::NoTabGroupForCurrentFocus { new_focus, .. }) => {\n        // documented recovery: adopt the computed target\n        input_focus.set(new_focus, FocusCause::Navigated);\n    }\n    Ok(next) => { input_focus.set(next, FocusCause::Navigated); }\n    Err(e) => warn!(\"{e}\"),\n}","preventionTips":["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."],"tags":["bevy","input-focus","tab-navigation","ui","keyboard","focus-recovery"],"backgroundTag":"element-outside-tab-order","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}