Repository navigation
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.29Found to occur in 3.29Found to occur in 3.29found in release: 3.32Found to occur in 3.32Found to occur in 3.32has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: pointer_interceptorA widget to prevent clicks from being swallowed by underlying HtmlElementViews on the webA widget to prevent clicks from being swallowed by underlying HtmlElementViews on the webpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-webOwned by Web platform teamOwned by Web platform teamtriaged-webTriaged by Web platform teamTriaged by Web platform team
Description
Steps to reproduce
On Flutter web, add on a stack a native widget and the Autocomplete widget, like this:
Stack(
children: <Widget>[
NativeWidget(),
PointerInterceptor(
child: AutocompleteWidget(),
)
]
)Expected results
Don't tap in the native widget.
Actual results
When some option is tapped in autocomplete, the PointerInterceptor did not work.
I tried to add PointerInterceptor in each element from optionsViewBuilder but the problem still persist.
Code sample
Code sample
import 'package:flutter/material.dart';
import 'dart:html' as html;
import 'dart:ui_web' as ui_web;
import 'package:pointer_interceptor/pointer_interceptor.dart';
const double _videoWidth = 640;
const double _videoHeight = 480;
void main() {
runApp(const MyApp());
}
/// Main app
class MyApp extends StatelessWidget {
/// Creates main app.
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Stopping Clicks with some DOM',
home: MyHomePage(),
);
}
}
/// First page
class MyHomePage extends StatefulWidget {
/// Creates first page.
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
List<String> clicks = <String>[];
@override
void initState() {
super.initState();
clicks.add('none');
}
void _clickedOn(String key) {
setState(() {
clicks.add(key);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('PointerInterceptor demo with Autocomplete'),
actions: <Widget>[
PointerInterceptor(
// debug: true,
child: IconButton(
icon: const Icon(Icons.add_alert),
tooltip: 'AppBar Icon',
onPressed: () {
_clickedOn('appbar-icon');
},
),
),
],
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Lasts click on: ${clicks..join(',')}',
key: const Key('last-clicked'),
),
Container(
color: Colors.black,
width: _videoWidth,
height: _videoHeight,
child: Stack(
alignment: Alignment.center,
children: <Widget>[
NativeWidget(
key: const ValueKey<String>('background-widget'),
onClick: () {
_clickedOn('native-element');
},
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
ElevatedButton(
key: const Key('transparent-button'),
child: const Text('Never calls onPressed'),
onPressed: () {
_clickedOn('transparent-button');
},
),
PointerInterceptor(
child: ElevatedButton(
key: const Key('clickable-button'),
child: const Text('Works As Expected'),
onPressed: () {
_clickedOn('clickable-button');
},
),
),
ExampleAutocomplete(
key: const Key('autocomplete'),
onSelect: () {
_clickedOn('autocomplete');
},
),
PointerInterceptor(
child: ExampleAutocomplete(
hint: 'Autocomplete with PointerInterceptor',
key: const Key(
'autocomplete-with-pointer-interceptor',
),
onSelect: () {
_clickedOn('autocomplete-with-pointer-interceptor');
},
),
),
],
),
],
),
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {
clicks.clear();
clicks.add('none');
});
},
tooltip: 'Clear clicks',
child: const Icon(Icons.delete),
),
);
}
}
html.Element htmlElement =
html.DivElement()
..style.width = '100%'
..style.height = '100%'
..style.backgroundColor = '#fabada'
..style.cursor = 'auto'
..id = 'background-html-view';
const String _htmlElementViewType = '_htmlElementViewType';
/// A widget representing an underlying html view
class NativeWidget extends StatelessWidget {
/// Constructor
const NativeWidget({super.key, required this.onClick});
/// A function to run when the element is clicked
final VoidCallback onClick;
@override
Widget build(BuildContext context) {
htmlElement.onClick.listen((_) {
onClick();
});
ui_web.platformViewRegistry.registerViewFactory(
_htmlElementViewType,
(int viewId) => htmlElement,
);
return const HtmlElementView(viewType: _htmlElementViewType);
}
}
class ExampleAutocomplete extends StatelessWidget {
ExampleAutocomplete({super.key, required this.onSelect, this.hint});
final VoidCallback onSelect;
final String? hint;
final fruits = <String>['apple', 'banana'];
@override
Widget build(BuildContext context) {
return Autocomplete<String>(
onSelected: (_) {
onSelect();
},
optionsBuilder: (value) => fruits,
fieldViewBuilder:
(context, textEditingController, focusNode, onFieldSubmitted) =>
TextField(
onTap: () => onSelect(),
controller: textEditingController,
focusNode: focusNode,
onSubmitted: (value) {
onFieldSubmitted();
},
decoration: InputDecoration(
hintText: hint ?? 'Autocomplete',
border: OutlineInputBorder(),
),
),
);
}
}
Screenshots or Video
Logs
No response
Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.29.2, on macOS 15.1.1 24B91 darwin-arm64, locale pt-BR) [520ms]
• Flutter version 3.29.2 on channel stable at /Users/consultorweb.arthur/Development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision c236373904 (6 weeks ago), 2025-03-13 16:17:06 -0400
• Engine revision 18b71d647a
• Dart version 3.7.2
• DevTools version 2.42.3
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [1.370ms]
• Android SDK at /Users/consultorweb.arthur/Library/Android/sdk
• Platform android-35, build-tools 34.0.0
• ANDROID_SDK_ROOT = /Users/consultorweb.arthur/Library/Android/sdk
• Java binary at: /Users/consultorweb.arthur/Library/Java/JavaVirtualMachines/azul-17.0.8/Contents/Home/bin/java
This JDK is specified in your Flutter configuration.
To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment Zulu17.44+15-CA (build 17.0.8+7-LTS)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.2) [900ms]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16C5032a
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web [11ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.2) [11ms]
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)
[✓] VS Code (version 1.99.3) [10ms]
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.108.0
[✓] Connected device (3 available) [6,0s]
• macOS (desktop) • macos • darwin-arm64 • macOS 15.1.1 24B91 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.1.1 24B91 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 135.0.7049.97
[✓] Network resources [399ms]
• All expected network resources are available.
• No issues found!Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.29Found to occur in 3.29Found to occur in 3.29found in release: 3.32Found to occur in 3.32Found to occur in 3.32has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: pointer_interceptorA widget to prevent clicks from being swallowed by underlying HtmlElementViews on the webA widget to prevent clicks from being swallowed by underlying HtmlElementViews on the webpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-webOwned by Web platform teamOwned by Web platform teamtriaged-webTriaged by Web platform teamTriaged by Web platform team
Activity
maheshj01 commentedon Apr 24, 2025
Hey @4rthurmonteiro, Thanks for filing the issue. I am able to reproduce the issue on stable and the master channel. It looks like Pointer interceptor is not taking overlays into account. Clicking on the options is passing the tap to native widgets
Screen.Recording.2025-04-23.at.21.38.04.mov
code sample
flutter doctor -v
master
stable
4rthurmonteiro commentedon Apr 24, 2025
hey @maheshj01 ! Yes, maybe something related with the
CompositedTransformFollowerin the_buildOptionsViewfunction.yjbanov commentedon May 7, 2025
This may be related to #144354. I'm not a framework expert, but I think the
Autocompletewidget itself is not the pop-up, so wrapping it inPointerInterceptorwon't help. The popup content needs to be wrapped inPointerInterceptor. Ideally the entire pop-up would be automatically wrapped (as part of us fixing #144354), but a workaround might be to wrap each individual option.harryterkelsen commentedon Nov 12, 2026
Linking to umbrella issue #190574 (Automatic Pointer Interceptors for Platform Views on Web): once automatic pointer interception is enabled by default on the web, Flutter overlays painted above
HtmlElementView/<iframe>platform views (including popup routes, modal barriers, andOverlayPortalfollowers) automatically receive hit-test proxies without needing manualPointerInterceptorwrappers.