@@ -612,6 +612,23 @@ class _LibraryBrowseTabState extends BaseLibraryTabState<PlexMetadata, LibraryBr
|
||||
}
|
||||
}
|
||||
|
||||
/// Navigate from the alpha jump bar to the nearest visible grid item.
|
||||
/// After a jump-scroll the previously focused item is off-screen (and its
|
||||
/// FocusNode detached), so we target the last-column item in the first
|
||||
/// visible row — the grid cell closest to the alpha bar.
|
||||
void _navigateToGridNearScroll() {
|
||||
if (items.isEmpty || _currentColumnCount < 1) return;
|
||||
|
||||
final row = _currentFirstVisibleIndex ~/ _currentColumnCount;
|
||||
final targetIndex = ((row + 1) * _currentColumnCount - 1).clamp(0, items.length - 1);
|
||||
|
||||
if (targetIndex == 0) {
|
||||
firstItemFocusNode.requestFocus();
|
||||
} else {
|
||||
getGridItemFocusNode(targetIndex, prefix: 'browse_grid_item').requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
/// Navigate focus from grid up to the grouping chip
|
||||
void _navigateToChips() {
|
||||
_groupingChipFocusNode.requestFocus();
|
||||
@@ -848,8 +865,8 @@ class _LibraryBrowseTabState extends BaseLibraryTabState<PlexMetadata, LibraryBr
|
||||
onJump: _jumpToIndex,
|
||||
currentFirstVisibleIndex: _currentFirstVisibleIndex,
|
||||
focusNode: _alphaJumpBarFocusNode,
|
||||
onNavigateLeft: _navigateToGrid,
|
||||
onBack: widget.onBack,
|
||||
onNavigateLeft: _navigateToGridNearScroll,
|
||||
onBack: _navigateToGridNearScroll,
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -75,21 +75,17 @@ class _AlphaJumpBarState extends State<AlphaJumpBar> {
|
||||
if (event.logicalKey == LogicalKeyboardKey.arrowUp) {
|
||||
if (_highlightedIndex > 0) {
|
||||
setState(() => _highlightedIndex--);
|
||||
_jumpToLetter(AlphaJumpHelper.allLetters[_highlightedIndex]);
|
||||
}
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
if (event.logicalKey == LogicalKeyboardKey.arrowDown) {
|
||||
if (_highlightedIndex < AlphaJumpHelper.allLetters.length - 1) {
|
||||
setState(() => _highlightedIndex++);
|
||||
_jumpToLetter(AlphaJumpHelper.allLetters[_highlightedIndex]);
|
||||
}
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
if (event.logicalKey == LogicalKeyboardKey.select ||
|
||||
event.logicalKey == LogicalKeyboardKey.enter ||
|
||||
event.logicalKey == LogicalKeyboardKey.gameButtonA) {
|
||||
_jumpToLetter(AlphaJumpHelper.allLetters[_highlightedIndex]);
|
||||
return KeyEventResult.handled;
|
||||
}
|
||||
if (event.logicalKey == LogicalKeyboardKey.arrowLeft) {
|
||||
widget.onNavigateLeft?.call();
|
||||
return KeyEventResult.handled;
|
||||
|
||||
Reference in New Issue
Block a user