Module: Thaum::Concerns::TabNavigation

Included in:
App
Defined in:
lib/thaum/concerns/tab_navigation.rb

Instance Method Summary collapse

Instance Method Details

#handle_tab_cycle(event) ⇒ Object

Called by the framework before App#on_key sees a bubbled :tab. Shift-Tab moves focus backward; plain Tab moves forward. The App’s on_key then runs with focus already updated (see spec — Tab pipeline).

When the focused Sigil is inside an Octagram, cycling is SCOPED to that Octagram’s focusable units first. Reaching the boundary bubbles to the parent scope (next outer Octagram, or the App), which treats the inner Octagram as a single unit. The App falls back to the flat focus_next/focus_prev path only when no Octagram boundaries are involved — preserving existing behavior for Octagram-free apps.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/thaum/concerns/tab_navigation.rb', line 16

def handle_tab_cycle(event)
  direction = event.shift? ? :prev : :next
  sigil = @focused_sigil

  if sigil && inside_octagram?(sigil)
    target = scoped_tab_target(sigil: sigil, direction: direction)
    focus(target) if target
  else
    direction == :next ? focus_next : focus_prev
  end
end