bevyengine/bevy · error · TabNavigationError

Failed to navigate to next focusable entity

Error message

Failed to navigate to next focusable entity

What it means

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.

Source

Thrown at crates/bevy_input_focus/src/tab_navigation.rs:142

    /// Navigate to the last focusable entity.
    ///
    /// This is commonly triggered by pressing End.
    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> {

View on GitHub (pinned to 396ca72708)

Solutions

  1. Give every TabGroup a unique order value so group sequencing is unambiguous.
  2. Keep TabIndex values within each group consistent with the intended visual order.
  3. When using modal groups, ensure each has at least one focusable child and that a non-modal group exists for global tabbing.

Example fix

// before: duplicate group orders
ui_root.insert(TabGroup::new(0));
dialog.insert(TabGroup::new(0)); // ambiguous ordering

// after: distinct orders
ui_root.insert(TabGroup::new(0));
dialog.insert(TabGroup::new(1));
Defensive patterns

Strategy: validation

Validate before calling

use bevy_ecs::prelude::*;
use bevy_input_focus::tab_navigation::TabGroup;

fn tab_group_orders_unique(groups: &Query<&TabGroup>) -> bool {
    let mut orders: Vec<i32> = groups.iter().map(|g| g.order).collect();
    orders.sort_unstable();
    orders.dedup();
    orders.len() == groups.iter().count()
}

Try / catch

match tab_nav.navigate(&input_focus, NavAction::Next) {
    Err(TabNavigationError::FailedToNavigateToNextFocusableEntity) => {
        // audit TabGroup::order and TabIndex values, keep focus put
    }
    Ok(next) => { input_focus.set(next, FocusCause::Navigated); }
    Err(e) => warn!("{e}"),
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20). Data as JSON: /api/errors/fed59dd52708820a. Report an issue: GitHub.