mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-07 21:48:14 -08:00
fix: Duplicate focusing issue
This commit is contained in:
parent
d61a8cf72c
commit
f25ed59a37
1 changed files with 5 additions and 2 deletions
|
|
@ -61,6 +61,7 @@ class _HorizontalListState extends ConsumerState<HorizontalList> with TickerProv
|
||||||
final contentPadding = 8.0;
|
final contentPadding = 8.0;
|
||||||
double? contentWidth;
|
double? contentWidth;
|
||||||
double? _firstItemWidth;
|
double? _firstItemWidth;
|
||||||
|
bool hasFocus = false;
|
||||||
|
|
||||||
AnimationController? _scrollAnimation;
|
AnimationController? _scrollAnimation;
|
||||||
|
|
||||||
|
|
@ -246,7 +247,8 @@ class _HorizontalListState extends ConsumerState<HorizontalList> with TickerProv
|
||||||
Focus(
|
Focus(
|
||||||
focusNode: parentNode,
|
focusNode: parentNode,
|
||||||
onFocusChange: (value) {
|
onFocusChange: (value) {
|
||||||
if (value) {
|
if (value && hasFocus != value) {
|
||||||
|
hasFocus = value;
|
||||||
final nodesOnSameRow = _nodesInRow(parentNode);
|
final nodesOnSameRow = _nodesInRow(parentNode);
|
||||||
final currentNode =
|
final currentNode =
|
||||||
nodesOnSameRow.contains(lastFocused) ? lastFocused : _firstFullyVisibleNode(context, nodesOnSameRow);
|
nodesOnSameRow.contains(lastFocused) ? lastFocused : _firstFullyVisibleNode(context, nodesOnSameRow);
|
||||||
|
|
@ -262,9 +264,10 @@ class _HorizontalListState extends ConsumerState<HorizontalList> with TickerProv
|
||||||
} else {
|
} else {
|
||||||
context.ensureVisible();
|
context.ensureVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
currentNode.requestFocus();
|
currentNode.requestFocus();
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
hasFocus = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: SizedBox(
|
child: SizedBox(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue