Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/pointer_interceptor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.9.0+1

* Change sizing of HtmlElementView so it works well when slotted.

## 0.9.0

* Migrates to null safety.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,24 @@ void main() {
find.byKey(const Key('clickable-button'));

testWidgets(
'on wrapped elements, the browser hits the interceptor (and not the background-html-view)',
'on wrapped elements, the browser does not hit the background-html-view',
(WidgetTester tester) async {
app.main();
await tester.pumpAndSettle();

final html.Element? element =
_getHtmlElementFromFinder(clickableButtonFinder, tester);
expect(element?.tagName.toLowerCase(), 'flt-platform-view');

final html.Element? platformViewRoot =
element?.shadowRoot?.getElementById('background-html-view');
expect(platformViewRoot, isNull);
if (html.document.querySelector('flt-glass-pane')?.shadowRoot != null) {
// In flutter master...
expect(element?.id, isNot('background-html-view'));
} else {
// In previous versions (--web-renderer=html only)...
expect(element?.tagName.toLowerCase(), 'flt-platform-view');
final html.Element? platformViewRoot =
element?.shadowRoot?.getElementById('background-html-view');
expect(platformViewRoot, isNull);
}
});

testWidgets(
Expand All @@ -43,11 +49,17 @@ void main() {

final html.Element? element =
_getHtmlElementFromFinder(nonClickableButtonFinder, tester);
expect(element?.tagName.toLowerCase(), 'flt-platform-view');

final html.Element? platformViewRoot =
element?.shadowRoot?.getElementById('background-html-view');
expect(platformViewRoot, isNotNull);
if (html.document.querySelector('flt-glass-pane')?.shadowRoot != null) {
// In flutter master...
expect(element?.id, 'background-html-view');
} else {
// In previous versions (--web-renderer=html only)...
expect(element?.tagName.toLowerCase(), 'flt-platform-view');
final html.Element? platformViewRoot =
element?.shadowRoot?.getElementById('background-html-view');
expect(platformViewRoot, isNotNull);
}
});
});
}
Expand Down
12 changes: 5 additions & 7 deletions packages/pointer_interceptor/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ html.Element htmlElement = html.DivElement()
// ..style.border = 'none';

void main() {
ui.platformViewRegistry.registerViewFactory(
_htmlElementViewType,
(int viewId) => htmlElement,
);

runApp(const MyApp());
}

Expand All @@ -52,13 +57,6 @@ class MyApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
ui.platformViewRegistry.registerViewFactory(_htmlElementViewType,
(int viewId) {
final html.Element wrapper = html.DivElement();
wrapper.append(htmlElement);
return wrapper;
});

return const MaterialApp(
title: 'Stopping Clicks with some DOM',
home: MyHomePage(),
Expand Down
7 changes: 2 additions & 5 deletions packages/pointer_interceptor/lib/src/web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@ void _registerFactory({bool debug = false}) {
final String viewType = _getViewType(debug: debug);
ui.platformViewRegistry.registerViewFactory(viewType, (int viewId) {
final html.Element htmlElement = html.DivElement()
..style.top = '0'
..style.right = '0'
..style.bottom = '0'
..style.left = '0'
..style.position = 'relative';
..style.width = '100%'
..style.height = '100%';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change fine for stable as well? (If not, you could always update the Flutter SDK requirement so Flutter 2.2 won't versions that have this change.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks for asking. I tested this both with stable and master, manually and with the driver tests.

This is backwards compatible, it's just that there's many ways to "cover a parent div" with CSS, but in the engine we only check "are style.width and style.height set (to any value?) else: warn user".

This code is to disable that warning from our own packages.

if (debug) {
htmlElement.style.backgroundColor = 'rgba(255, 0, 0, .5)';
}
Expand Down
2 changes: 1 addition & 1 deletion packages/pointer_interceptor/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: pointer_interceptor
description: A widget to prevent clicks from being swallowed by underlying HtmlElementViews on the web.
repository: https://github.com/flutter/packages
version: 0.9.0
version: 0.9.0+1

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down