{"record":{"id":"fed59dd52708820a","repo":"bevyengine/bevy","slug":"failed-to-navigate-to-next-focusable-entity","errorCode":null,"errorMessage":"Failed to navigate to next focusable entity","messagePattern":"Failed to navigate to next focusable entity","errorType":"exception","errorClass":"TabNavigationError","httpStatus":null,"severity":"error","filePath":"crates/bevy_input_focus/src/tab_navigation.rs","lineNumber":142,"sourceCode":"    /// Navigate to the last focusable entity.\n    ///\n    /// This is commonly triggered by pressing End.\n    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> {","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_input_focus/src/tab_navigation.rs#L124-L160","documentation":"TabNavigation failed to compute the next (or previous) focusable entity even though groups and focusable entities exist. The doc comment attributes this to malformed tab groups: the ordering pass over (TabGroup::order, TabIndex, hierarchy order) cannot produce a valid successor for the requested NavAction.","triggerScenarios":"Calling navigate(NavAction::Next/Previous/First/Last) where duplicated TabGroup::order values, inconsistent TabIndex values, or modal/non-modal group mixing leave the sorted sequence without a resolvable target.","commonSituations":"Copy-pasted groups all using order 0; TabIndex values not updated after reordering UI elements; a modal group with no focusable children while global tabbing is expected.","solutions":["Give every TabGroup a unique order value so group sequencing is unambiguous.","Keep TabIndex values within each group consistent with the intended visual order.","When using modal groups, ensure each has at least one focusable child and that a non-modal group exists for global tabbing."],"exampleFix":"// before: duplicate group orders\nui_root.insert(TabGroup::new(0));\ndialog.insert(TabGroup::new(0)); // ambiguous ordering\n\n// after: distinct orders\nui_root.insert(TabGroup::new(0));\ndialog.insert(TabGroup::new(1));","handlingStrategy":"validation","validationCode":"use bevy_ecs::prelude::*;\nuse bevy_input_focus::tab_navigation::TabGroup;\n\nfn tab_group_orders_unique(groups: &Query<&TabGroup>) -> bool {\n    let mut orders: Vec<i32> = groups.iter().map(|g| g.order).collect();\n    orders.sort_unstable();\n    orders.dedup();\n    orders.len() == groups.iter().count()\n}","typeGuard":null,"tryCatchPattern":"match tab_nav.navigate(&input_focus, NavAction::Next) {\n    Err(TabNavigationError::FailedToNavigateToNextFocusableEntity) => {\n        // audit TabGroup::order and TabIndex values, keep focus put\n    }\n    Ok(next) => { input_focus.set(next, FocusCause::Navigated); }\n    Err(e) => warn!(\"{e}\"),\n}","preventionTips":["Use unique TabGroup::order values everywhere.","Keep TabIndex assignments in sync with visual order during UI refactors.","Add a debug system that validates tab configuration on menu open."],"tags":["bevy","input-focus","tab-navigation","ui","keyboard","ordering"],"backgroundTag":"tab-order-misconfigured","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"}