Skip to content

[Web] SemanticsBinding.instance.ensureSemantics makes ui irresponsive #163204

@sharabiddin

Description

@sharabiddin

Steps to reproduce

  1. add SemanticsBinding.instance.ensureSemantics();
  2. Create widget tree with overlay portal
  3. Try to click on an item on the overlay portal's child
  4. The area behind overlay will be clickable

note:

to reproduce please follow "Click here" part of example code,

Expected results

SemanticsBinding.instance.ensureSemantics(); must not change ui behaviour, but it does

Actual results

Child of overlay portal loses hit functionality, that is not clickable

Code sample

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

void main() {
  runApp(const MyApp());
  //Uncomment this and recheck to reproduce the issue
  // SemanticsBinding.instance.ensureSemantics();
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(title: 'Flutter Demo', home: MyHomePage(title: 'Flutter Demo Home Page'));
  }
}

class MyHomePage extends StatelessWidget {
  MyHomePage({super.key, required this.title});

  final OverlayPortalController controller = OverlayPortalController();
  final String title;

  @override
  Widget build(BuildContext context) => Scaffold(
    appBar: AppBar(title: Text(title)),
    body: Center(
      child: Column(
        children: [
          OverlayPortal(
            controller: controller,
            overlayChildBuilder:
                (BuildContext context) => Column(
                  children: [
                    InkWell(
                      onTap: () {
                        print("Tapped");
                      },
                      child: Container(
                        height: 200,
                        width: 300,
                        color: Colors.red,
                        child: Center(child: Text("Click here")),
                      ),
                    ),
                  ],
                ),

            child: InkWell(
              onTap: () {
                if (controller.isShowing) {
                  controller.hide();
                } else {
                  controller.show();
                }
              },
              child: Text("Click here"),
            ),
          ),
          TextField(),
        ],
      ),
    ),
  );
}

Screenshots or Video

Screenshots / Video demonstration
Screen.Recording.2025-02-13.at.3.14.18.PM.mov

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.29.0, on macOS 15.0.1 24A348
    darwin-arm64, locale en-TR)
[✓] Android toolchain - develop for Android devices (Android SDK
    version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.2)
[✓] VS Code (version 1.82.2)
[✓] Connected device (5 available)
[✓] Network resources

• No issues found!

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)c: regressionIt was better in the past than it is nowfound in release: 3.29Found to occur in 3.29found in release: 3.30Found to occur in 3.30has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyr: duplicateIssue is closed as a duplicate of an existing issueteam-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