Visitar URL original
[web] Anchor flt-semantics-host at 0,0 to fix WebKit semantics offset by flutter-zl · Pull Request #190486 · flutter/flutter · GitHub
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ class StyleManager {
assert(semanticsHost.tagName.toLowerCase() == DomManager.semanticsHostTagName.toLowerCase());
semanticsHost.style
..position = 'absolute'
// Anchor the host at the view origin. Without an explicit left/top, this
// position:absolute element falls back to its static position. On WebKit
// (all iOS browsers) that static position is flowed past the in-flow
// sibling hosts (flt-glass-pane, one viewport wide), offsetting every
// semantic element horizontally so taps on text fields land off the
// <input> and the keyboard never opens. Blink and Gecko resolve the same
// static position to 0, so this is a no-op there.
// See: https://github.com/flutter/flutter/issues/190483
..left = '0'
..top = '0'
..transformOrigin = '0 0 0';
scaleSemanticsHost(semanticsHost, devicePixelRatio);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ void doTests() {
StyleManager.styleSemanticsHost(semanticsHost, 4.0);
expect(semanticsHost.style.transform, 'scale(0.25)');
expect(semanticsHost.style.position, 'absolute');
// The host must be anchored at the view origin. Without an explicit
// left/top it falls back to a static position flowed after its sibling
// hosts, offsetting the whole semantics tree. See:
// https://github.com/flutter/flutter/issues/190483
expect(semanticsHost.style.left, '0px');
expect(semanticsHost.style.top, '0px');
expect(semanticsHost.style.transformOrigin, anyOf('0px 0px 0px', '0px 0px'));
});

Expand Down