Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit e9e601c

Browse files
authored
[web] Hide autofill overlay (#39294)
* Make autofill styling transparent * Formatting * Add tests * Modify tests * Add correct prefix for safari and firefox tests
1 parent 388890a commit e9e601c

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

lib/web_ui/lib/src/engine/host_node.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,16 +317,16 @@ void applyGlobalCssRulesToSheet(
317317
}
318318
''', sheet.cssRules.length);
319319

320-
// This css prevents an autofill overlay brought by the browser during
321-
// text field autofill by delaying the transition effect.
322-
// See: https://github.com/flutter/flutter/issues/61132.
320+
// This CSS makes the autofill overlay transparent in order to prevent it
321+
// from overlaying on top of Flutter-rendered text inputs.
322+
// See: https://github.com/flutter/flutter/issues/118337.
323323
if (browserHasAutofillOverlay()) {
324324
sheet.insertRule('''
325325
$cssSelectorPrefix .transparentTextEditing:-webkit-autofill,
326326
$cssSelectorPrefix .transparentTextEditing:-webkit-autofill:hover,
327327
$cssSelectorPrefix .transparentTextEditing:-webkit-autofill:focus,
328328
$cssSelectorPrefix .transparentTextEditing:-webkit-autofill:active {
329-
-webkit-transition-delay: 99999s;
329+
opacity: 0 !important;
330330
}
331331
''', sheet.cssRules.length);
332332
}

lib/web_ui/test/engine/host_node_test.dart

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,31 @@ void testMain() {
112112
expect(hidesRevealIcons, isFalse);
113113
}, skip: isEdge);
114114

115+
test(
116+
'Attaches styles to hide the autofill overlay for browsers that support it',
117+
() {
118+
final DomElement? style =
119+
hostNode.querySelector('#flt-internals-stylesheet');
120+
final String vendorPrefix = (isSafari || isFirefox) ? '' : '-webkit-';
121+
final bool autofillOverlay = hasCssRule(style,
122+
selector: '.transparentTextEditing:${vendorPrefix}autofill',
123+
declaration: 'opacity: 0 !important');
124+
final bool autofillOverlayHovered = hasCssRule(style,
125+
selector: '.transparentTextEditing:${vendorPrefix}autofill:hover',
126+
declaration: 'opacity: 0 !important');
127+
final bool autofillOverlayFocused = hasCssRule(style,
128+
selector: '.transparentTextEditing:${vendorPrefix}autofill:focus',
129+
declaration: 'opacity: 0 !important');
130+
final bool autofillOverlayActive = hasCssRule(style,
131+
selector: '.transparentTextEditing:${vendorPrefix}autofill:active',
132+
declaration: 'opacity: 0 !important');
133+
134+
expect(autofillOverlay, isTrue);
135+
expect(autofillOverlayHovered, isTrue);
136+
expect(autofillOverlayFocused, isTrue);
137+
expect(autofillOverlayActive, isTrue);
138+
}, skip: !browserHasAutofillOverlay());
139+
115140
_runDomTests(hostNode);
116141
});
117142

0 commit comments

Comments
 (0)