Skip to content

Provide a parameter to update Focus semantics under FocusableActionDetector #115831

Description

@TahaTesser

Currently, it's not possible to update Focus's semantics under FocusableActionDetector.

FocusableActionDetector needs to provide a parameter for Focus's semantics. For cases, when you need focus but without semantics just like the Focus.includeSemantics widget.

I ran into an issue in #115285 where the Focus's semantics take over Slider semantics and it's not possible to focus on Slider from Slider's own semantics.

code sample
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      showSemanticsDebugger: true,
      home: Example(),
    );
  }
}

class Example extends StatefulWidget {
  const Example({super.key});

  @override
  State<Example> createState() => _ExampleState();
}

class _ExampleState extends State<Example> {
  FocusNode focusNode1 = FocusNode();
  FocusNode focusNode2 = FocusNode();

  @override
  void dispose() {
    focusNode1.dispose();
    focusNode2.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Example'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: <Widget>[
            FocusableActionDetector(
              focusNode: focusNode1,
              onFocusChange: (bool value) {
                print('FocusableActionDetector.onFocusChange called');
              },
              // includeFocusSemantics: false, // This is passed to internal Focus widget.
              child: Container(
                width: 50,
                height: 50,
                color: Colors.red,
              ),
            ),
            Focus(
              focusNode: focusNode2,
              onFocusChange: (bool value) {
                print('Focus.onFocusChange called');
              },
              includeSemantics: false,
              child: Container(
                width: 50,
                height: 50,
                color: Colors.blue,
              ),
            )
          ],
        ),
      ),
    );
  }
}
Current Expected

Activity

  1. added
    in triagePresently being triaged by the triage team
    frameworkflutter/packages/flutter repository. See also f: labels.
    a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)
    f: focusFocus traversal, gaining or losing focus
    and removed
    in triagePresently being triaged by the triage team
    on Nov 22, 2022
  2. self-assigned this
    on Nov 22, 2022
  3. moved this to To do in Nevercodeon Nov 22, 2022
  4. moved this from To do to PR submitted in Nevercodeon Nov 22, 2022
  5. Repository owner moved this from PR submitted to Done (PR merged) in Nevercodeon Nov 22, 2022
  6. github-actions commented on Mar 5, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  7. locked as resolved and limited conversation to collaborators on Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)f: focusFocus traversal, gaining or losing focusframeworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

  • Status
    Done (PR merged)

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions