FocusScope
FocusScope groups keyboard focus within a subtree. Set is_barrier to
true when focus must not move into surrounding content.
Use it for dialogs, popovers, menus, or embedded editors. It does not change
layout; use the normal layout widgets for spacing or stacking.
Example
use fission::prelude::*;
fission_component! {
pub EditorFocusRegion<()> {
props { editor: Widget }
}
view(region, _state, _cx) =>
FocusScope(
is_barrier: false,
children: [region.editor.clone()],
)
}
An inline editor can have a focus region without trapping traversal. A real
blocking overlay needs a barrier plus dismissal and focus restoration; prefer
Modal for that complete behaviour. A single unbound input inside an arbitrary
barrier is not a usable dialog.
This is the kind of structure you want inside a modal, where keyboard users should stay inside the dialog while it is open.
Field table
| | | |
|---|
| | | |
| | The subtree inside the focus scope. | Defaults to an empty list. |
| | Whether focus traversal should be contained by this scope. | Defaults to false. Set true for modal-style focus containment. |
Focus and semantics behavior
FocusScope lowers its children under a semantics node marked as a focus scope. It is primarily about focus behavior and accessibility structure, not about visuals. The children are wrapped together so the runtime can treat them as one focus region.
When is_barrier is true, this becomes the right tool for modal flows where tabbing or keyboard focus should not fall through to controls behind the overlay.
Specific advice
Use FocusScope deliberately. Overusing focus barriers can make keyboard navigation feel trapped in the wrong places. The barrier mode is excellent for real dialogs and overlays, but it is usually wrong for ordinary in-page sections.
Pair FocusScope with clear visible structure, such as a titled modal or panel, so the accessibility structure matches what the user sees.
Production checklist
Test Tab and reverse Tab through and out of the inline region.
Use a barrier only where the user has an accessible way to finish or dismiss.
Test focus restoration when a transient scope unmounts.