perf(tv): trim media card focus semantics
This commit is contained in:
@@ -199,6 +199,12 @@ class FocusableWrapper extends StatefulWidget {
|
||||
/// that would compete with this wrapper's focus handling.
|
||||
final bool descendantsAreFocusable;
|
||||
|
||||
/// Whether the [Focus] node contributes focusable/focused semantics.
|
||||
///
|
||||
/// Keep this enabled unless an equivalent child semantic action remains and
|
||||
/// accessibility navigation is known to be inactive.
|
||||
final bool includeFocusSemantics;
|
||||
|
||||
const FocusableWrapper({
|
||||
super.key,
|
||||
required this.child,
|
||||
@@ -232,6 +238,7 @@ class FocusableWrapper extends StatefulWidget {
|
||||
this.useFocusGlow = false,
|
||||
this.delegateFocusBorder = false,
|
||||
this.descendantsAreFocusable = true,
|
||||
this.includeFocusSemantics = true,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -587,6 +594,7 @@ class _FocusableWrapperState extends State<FocusableWrapper> with SingleTickerPr
|
||||
Widget result = Focus(
|
||||
focusNode: _focusNode,
|
||||
autofocus: widget.autofocus,
|
||||
includeSemantics: widget.includeFocusSemantics,
|
||||
descendantsAreFocusable: widget.descendantsAreFocusable,
|
||||
onFocusChange: _handleFocusChange,
|
||||
onKeyEvent: _handleKeyEvent,
|
||||
|
||||
@@ -118,6 +118,10 @@ class _FocusableMediaCardState extends State<FocusableMediaCard> {
|
||||
Widget build(BuildContext context) {
|
||||
return FocusableWrapper(
|
||||
focusNode: widget.focusNode,
|
||||
// The MediaCard already exposes the complete static button semantics.
|
||||
// Avoid invalidating a dense TV grid's semantics tree on every D-pad
|
||||
// focus change unless an accessibility service needs focused state.
|
||||
includeFocusSemantics: !PlatformDetector.isTV() || MediaQuery.accessibleNavigationOf(context),
|
||||
onSelect: () => _mediaCardKey.currentState?.handleTap(),
|
||||
onLongPress: () => _mediaCardKey.currentState?.showContextMenu(),
|
||||
onNavigateUp: widget.onNavigateUp,
|
||||
|
||||
Reference in New Issue
Block a user