flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
164.98k stars 27.18k forks source link

Flutter Web : Semantic identifier is not working correctly on TextFields #155323

Open MERCE072 opened 1 day ago

MERCE072 commented 1 day ago

Steps to reproduce

semantic identifier is not created when the element is a TextField,

Expected results

the semantic identifier must be created in the same way that the TextButton identifier is created.

Actual results

semantic identifier is not created "flt-semantics-identifier=search_field "

Code sample

Code sample ```dart import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/semantics.dart'; void main() { WidgetsFlutterBinding.ensureInitialized(); runApp(const MyApp()); if (kIsWeb) { SemanticsBinding.instance.ensureSemantics(); } } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData.light(), home: Scaffold( body: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Semantics( identifier: 'search_field', child: const TextField( decoration: InputDecoration( border: OutlineInputBorder(), hintText: 'Enter a search term', ), ), ), Semantics( identifier: 'text_button', child: TextButton( style: ButtonStyle( foregroundColor: WidgetStateProperty.all(Colors.blue), ), onPressed: () {}, child: const Text('TextButton'), ), ), ], ), ), ); } } ```

Screenshots or Video

Screenshots / Video demonstration Screenshot 2024-09-17 at 4 21 18 PM

Logs

Logs ```console [Paste your logs here] ```

Flutter Doctor output

Doctor output ```console Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel stable, 3.24.1, on macOS 14.6.1 23G93 darwin-x64, locale en-CO) [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 16.0) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.2) [✗] Cannot determine if IntelliJ is installed ✗ Directory listing failed [✓] VS Code (version 1.86.1) [✓] Connected device (2 available) [✓] Network resources ```
darshankawar commented 1 day ago

Thanks for the report. I was able to replicate the reported behavior on latest stable and master versions.

Screenshot 2024-09-18 at 1 38 57 PM

There may be a similar / related issue with textfield's semantics on web like https://github.com/flutter/flutter/issues/97455

Stable : 3.24.3
Master : 3.26.0-1.0.pre.152