bevyengine/bevy · warning · DirectionalNavigationError
No focusable entity is currently set.
Error message
No focusable entity is currently set.
What it means
Returned by DirectionalNavigation::navigate (crates/bevy_input_focus/src/directional_navigation.rs:410) when the InputFocus resource holds no focused entity. Directional navigation finds the neighbor of the currently focused entity in a CompassOctant direction; with no focus set there is no origin entity to search from, so the call fails before any map lookup happens.
Source
Thrown at crates/bevy_input_focus/src/directional_navigation.rs:440
current_focus,
direction,
}),
NavNeighbor::Set(new_focus) => {
self.focus.set(new_focus, FocusCause::Navigated);
Ok(new_focus)
}
}
} else {
Err(DirectionalNavigationError::NoFocus)
}
}
}
/// An error that can occur when navigating between focusable entities using [directional navigation](crate::directional_navigation).
#[derive(Debug, PartialEq, Clone, Error)]
pub enum DirectionalNavigationError {
/// No focusable entity is currently set.
#[error("No focusable entity is currently set.")]
NoFocus,
/// No neighbor in the requested direction.
#[error("No neighbor from {current_focus} in the {direction:?} direction.")]
NoNeighborInDirection {
/// The entity that was the focus when the error occurred.
current_focus: Entity,
/// The direction in which the navigation was attempted.
direction: CompassOctant,
},
/// Navigation explicitly blocked in the requested direction.
#[error("Navigation explicitly blocked from {current_focus} in the {direction:?} direction.")]
BlockedNavigation {
/// The entity that was the focus when the error occurred.
current_focus: Entity,
/// The direction in which the navigation was attempted.
direction: CompassOctant,
},
}View on GitHub (pinned to 396ca72708)
Solutions
- Set an initial focus when the UI opens: TabNavigation::initialize(menu_root, NavAction::Next) then input_focus.set(entity, FocusCause::Navigated), or set InputFocus directly to a default Focusable entity.
- Handle Err(DirectionalNavigationError::NoFocus) by picking the first focusable entity and focusing it instead of propagating the error.
- When despawning the currently focused entity, clear or transfer InputFocus in the same frame.
Example fix
// before
let next = nav.navigate(CompassOctant::East)?; // fails when nothing is focused
// after
match nav.navigate(CompassOctant::East) {
Ok(next) => debug!("focused {next}"),
Err(DirectionalNavigationError::NoFocus) => {
if let Ok(first) = tab_nav.initialize(menu_root, NavAction::Next) {
input_focus.set(first, FocusCause::Navigated);
}
}
Err(e) => warn!("navigation failed: {e}"),
} Defensive patterns
Strategy: validation
Validate before calling
use bevy_input_focus::prelude::*;
fn can_navigate(input_focus: &InputFocus) -> bool {
input_focus.get().is_some()
}
// in your system:
if can_navigate(&input_focus) {
let _ = nav.navigate(direction);
} else {
// set an initial focus first, e.g. via TabNavigation::initialize
} Try / catch
match nav.navigate(direction) {
Ok(entity) => debug!("focused {entity}"),
Err(DirectionalNavigationError::NoFocus) => { /* pick and set an initial Focusable */ }
Err(e) => warn!("navigation failed: {e}"),
} Prevention
- Set an initial focus whenever a navigable UI becomes visible.
- Clear or transfer focus when despawning the focused entity.
- Treat NoFocus as an expected recoverable case, never unwrap() navigate results.
When it happens
Trigger: Calling DirectionalNavigation::navigate(direction) (or gamepad/arrow-key input driving it) while InputFocus::get() returns None. Common on the first frames of a UI that never set an initial focus, or right after the focused entity was despawned or focus was cleared.
Common situations: A menu scene that never assigns an initial focus; the focused button is despawned when a submenu closes; focus was cleared and the player presses a d-pad direction; game builds where only keyboard users hit it because mouse users always click first.
Related errors
- No neighbor from {current_focus} in the {direction:?} direct
- Navigation explicitly blocked from {current_focus} in the {d
- No tab groups found
- No focusable entities found
- Failed to navigate to next focusable entity
AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20).
Data as JSON: /api/errors/bdcb7996f8b895a0.
Report an issue: GitHub.