app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

commit d829181a5d3bfaaa16983eabe72097d2533f8255
parent f199a075f9437e79596dce567ac1a11a33bb4295
Author: triesap <tyson@radroots.org>
Date:   Tue, 27 Jan 2026 14:18:59 +0000

ui: migrate roving focus helpers

- route roving focus index changes through ui-primitives-core

- preserve existing action key mapping behavior

- keep public RadrootsAppUiRovingFocus API stable

- retain unit tests for key and loop handling

Diffstat:
Mcrates/ui-primitives/src/roving_focus.rs | 32++++++++------------------------
1 file changed, 8 insertions(+), 24 deletions(-)

diff --git a/crates/ui-primitives/src/roving_focus.rs b/crates/ui-primitives/src/roving_focus.rs @@ -1,3 +1,5 @@ +use ui_primitives_core::roving_focus::RovingFocus; + #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum RadrootsAppUiRovingFocusOrientation { Horizontal, @@ -53,31 +55,13 @@ pub fn radroots_app_ui_roving_focus_next_index( if count == 0 { return 0; } + + let mut focus = RovingFocus::with_active(count, Some(current), looped); match action { - RadrootsAppUiRovingFocusAction::First => 0, - RadrootsAppUiRovingFocusAction::Last => count.saturating_sub(1), - RadrootsAppUiRovingFocusAction::Next => { - if current + 1 >= count { - if looped { - 0 - } else { - current - } - } else { - current + 1 - } - } - RadrootsAppUiRovingFocusAction::Prev => { - if current == 0 { - if looped { - count.saturating_sub(1) - } else { - 0 - } - } else { - current - 1 - } - } + RadrootsAppUiRovingFocusAction::First => focus.move_first().unwrap_or(0), + RadrootsAppUiRovingFocusAction::Last => focus.move_last().unwrap_or(0), + RadrootsAppUiRovingFocusAction::Next => focus.move_next().unwrap_or(current), + RadrootsAppUiRovingFocusAction::Prev => focus.move_prev().unwrap_or(current), } }