Skip to content

Semantics excludeSemantics breaks aria-label on flutter web <input> for TextFormField #172206

Open

Description

@itsnits

Steps to reproduce

  1. Create a TextFormField wrapped with a Semantics widget.
  2. Add a label and set excludeSemantics: true.
  3. Run on Flutter Web using flutter build web.
  4. Try to inspect the generated element.
  5. Observe that aria-label, it will come as 'Login_email' which is provided in Semantics Label
  6. Now set excludeSemantics: false and run the Flutter web.
  7. Try to inspect the generated element
  8. Observe the aria-label, it will come as 'Email', which is the hint text provided in the TextFormField. 'Login_email' label is not coming in this case

Tested on Chrome stable version 138.0.7204.101

Expected results

  • The should have aria-label="Login_email" so it can be used in web automation tools like Selenium/Cypress.

  • Excluding the child semantics should still allow mapping the label (i.e 'Login_email' in my case) to the native input.

Actual results

  • Input cannot be typed into programmatically (via Playwright/Selenium/Cypress) in flutter web when excludeSemantics is set to true.

  • If excludeSemantics: false, aria-label is coming as 'Email' (which is Hint text in InputDecoration of TextFormField, not the one which I am providing in labels of Semantics widget ) and input is interactive in flutter web. We can't use Hint text as semantics label as we are using language support and Hint Text can be changed based on selected language.

Code sample

Code sample
import 'package:flutter/material.dart';
import 'package:flutter/semantics.dart';

void main() {
  runApp(const MyApp());
  Future.delayed(const Duration(seconds: 20), () {
    SemanticsBinding.instance.ensureSemantics();
  });
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Semantics Bug Demo',
      home: Scaffold(
        appBar: AppBar(title: const Text('Semantics Bug')),
        body: const Center(
          child: Padding(
            padding: EdgeInsets.all(16.0),
            child: LoginForm(),
          ),
        ),
      ),
    );
  }
}

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

  @override
  State<LoginForm> createState() => _LoginFormState();
}

class _LoginFormState extends State<LoginForm> {
  final _formKey = GlobalKey<FormState>();
  final TextEditingController _emailController = TextEditingController();
  final FocusNode _emailFocusNode = FocusNode();

  @override
  Widget build(BuildContext context) {
    return Form(
      key: _formKey,
      child: Semantics(
        label: 'Login_email',
        container: true,
        excludeSemantics: true,
        explicitChildNodes: true,
        textField: true,
        enabled: true,
        child: TextFormField(
          controller: _emailController,
          focusNode: _emailFocusNode,
          decoration: const InputDecoration(
            hintText: 'Email',
          ),
          validator: (value) {
            if (_emailFocusNode.hasFocus) return null;
            if (value == null || value.isEmpty) return 'Email is required';
            return null;
          },
        ),
      ),
    );
  }
}

Screenshots or Video

Screenshots / Video demonstration Image Image

Logs

Logs
Launching lib\main.dart on Chrome in debug mode...
This app is linked to the debug service: ws://127.0.0.1:63316/aE8KBBVWFXo=/ws
Debug service listening on ws://127.0.0.1:63316/aE8KBBVWFXo=/ws
Connecting to VM Service at ws://127.0.0.1:63316/aE8KBBVWFXo=/ws
Connected to the VM Service.

Flutter Doctor output

Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.27.0, on Microsoft Windows [Version 10.0.22631.5624], locale en-IN)
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
[√] Chrome - develop for the web
[!] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.46)
    X The current Visual Studio installation is incomplete.
      Please use Visual Studio Installer to complete the installation or reinstall Visual Studio.
[√] Android Studio (version 2024.1)
[√] VS Code (version 1.102.0)
[√] Connected device (3 available)
[√] Network resources

! Doctor found issues in 1 category.

Activity

  1. darshankawar commented on Jul 16, 2025

    @darshankawar
    Member

    Thanks for the report @itsnits
    I tried the code sample with latest stable and master versions and observed that the aria-label=Login_email in intact after setting ExcludeSemantics to true and false, both.

    1. With true:
    Image
    1. With false:
    Image

    Please try by upgrading to latest sdk as there have been few fixes made related to aria label recently.

  2. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 16, 2025
  3. itsnits commented on Jul 16, 2025

    @itsnits
    Author

    Thanks @darshankawar for checking this.

    As confirmed by you, I have checked this with the latest stable flutter version 3.32.6.

    1. with excludeSemantics: true, I am getting semantic label correctly as it was in earlier version.
    Image
    1. But with excludeSemantics : false, I am getting two input tags. One with aria-label = "Login_email" and the other with aria-label = "Email". I am attaching the screenshot for reference. So in this case
    • Input is not interactive with "Login_email" label in flutter web automation
    • Input is interactive with "Email" label, but this should work with "Login_email" label.
    Image Image

    Please check this.

    Flutter doctor output

    Doctor summary (to see all details, run flutter doctor -v):
    [√] Flutter (Channel stable, 3.32.6, on Microsoft Windows [Version 10.0.22631.5624], locale en-IN)
    [√] Windows Version (11 Enterprise 64-bit, 23H2, 2009)
    [√] Android toolchain - develop for Android devices (Android SDK version 35.0.1)
    [√] Chrome - develop for the web
    [!] Visual Studio - develop Windows apps (Visual Studio Build Tools 2019 16.11.46)
        X The current Visual Studio installation is incomplete.
          Please use Visual Studio Installer to complete the installation or reinstall Visual Studio.
    [√] Android Studio (version 2024.1)
    [√] VS Code (version 1.102.0)
    [√] Connected device (3 available)
    [√] Network resources
    
    ! Doctor found issues in 1 category
    
    
  4. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Jul 16, 2025
  5. darshankawar commented on Jul 17, 2025

    @darshankawar
    Member

    Thanks for the update. Yes, I see the same behavior.

    1. With true:
    Image
    1. With false:
    Image Image
    stable : 3.32.6
    master : 3.33.0-1.0.pre-1005
    
  6. added
    platform-webWeb applications specifically
    a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)
    team-webOwned by Web platform team
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    and removed
    in triagePresently being triaged by the triage team
    on Jul 17, 2025
  7. itsnits commented on Jul 22, 2025

    @itsnits
    Author

    Hi @darshankawar,

    Thanks for confirming the issue and reproducing it.

    I just wanted to check on the next steps. Is there anything else required from my side to assist further?
    Also, could you please let me know if a fix is planned for an upcoming release?

    Appreciate your support!

  8. 11 remaining items

  9. added
    P2Important issues not at the top of the work list
    triaged-webTriaged by Web platform team
    on Aug 13, 2025
  10. itsnits commented on Sep 8, 2025

    @itsnits
    Author
  11. darshankawar commented on Sep 8, 2025

    @darshankawar
    Member
  12. self-assigned this
    on Jun 30, 2026
  13. added
    P1High-priority issues at the top of the work list
    and removed
    P2Important issues not at the top of the work list
    on Jun 30, 2026
  14. removed
    P1High-priority issues at the top of the work list
    on Aug 7, 2026
  15. removed their assignment
    on Aug 7, 2026
  16. flutter-triage-bot commented on Aug 25, 2026

    @flutter-triage-bot

    This issue is missing a priority label. Please set a priority label when adding the triaged-web label.

  17. added
    P2Important issues not at the top of the work list
    triaged-webTriaged by Web platform team
    on Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)a: text inputEntering text in a text field or keyboard related problemsfound in release: 3.32Found to occur in 3.32found in release: 3.33Found to occur in 3.33has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions