focusPreviousPage method

void focusPreviousPage()

Focus previous page. Port of focus-previous-page action from use-select-navigation.ts reducer.

Implementation

void focusPreviousPage() {
  final current = focusedValue.value;
  if (current == null) return;

  final item = optionMap.get(current);
  if (item == null) return;

  final targetIndex = math.max(0, item.index - visibleOptionCount);

  OptionMapItem<T>? target = optionMap.first;
  for (int i = 0; i < targetIndex && target != null; i++) {
    target = target.next;
  }
  if (target == null) return;

  focusedValue.value = target.value;
  _scrollToFocus();
  onFocus?.call(target.value);
}