-
Notifications
You must be signed in to change notification settings - Fork 6k
Fix iOS safari keyboard issue when semantics is enabled #38822
Conversation
| Timer? _positionInputElementTimer; | ||
| static const Duration _delayBeforePlacement = Duration(milliseconds: 100); | ||
|
|
||
| void _createEditableElement() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it legal to call this method if editableElement != null? If not, should we add an assert that checks that this doesn't happen by mistake?
nit: "create" is typically used for functions that return the value that's created, but this method creates and assigns it to a field but returns nothing. For such methods a more common verb is "initialize".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
| activeEditableElement.style.transform = 'translate(-999px,-999px)'; | ||
| _positionInputElementTimer?.cancel(); | ||
| _positionInputElementTimer = Timer(_delayBeforePlacement, () { | ||
| editableElement?.style.transform = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to null out _positionInputElementTimer when it fires to avoid having a stale timer object lurking in the system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Done!
| }); | ||
|
|
||
| activeEditableElement.focus(); | ||
| semanticsObject.element.removeAttribute('role'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this to avoid having two elements with the "textfield" role representing the same text field? If so, might be worth leaving a comment explaining it for a future reader.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, VoiceOver starts acting weird if we don't remove the role.
Sure! I added some comments.
| _hasFocused = false; | ||
| @override | ||
| void update() { | ||
| if (editableElement != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all the editableElement != null checks can be combined into one top-level check, so that we don't need to check it again multiple times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, you're right.
| editableElement.remove(); | ||
| _positionInputElementTimer?.cancel(); | ||
| _positionInputElementTimer = null; | ||
| activeEditableElement.remove(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we guaranteed to have an activeEditableElement? If not, this can throw. I can imagine a text field to never be focused and disposed. Also, we might want to have a test for disposing both focused and unfocused text fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Done!
| expect(await logger.actionLog.first, ui.SemanticsAction.tap); | ||
| }); | ||
|
|
||
| test('Syncs editing state from framework', () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's an extra indent compared to sigling tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
| }); | ||
| }, skip: isIosSafari); | ||
|
|
||
| group('$SemanticsTextEditingStrategy in iOS', () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're only emulating iOS here, we probably want to limit the number of browsers we run this on to avoid browser quirks. I think we should pick one browser that's closest to iOS Safari, which I think is macOS Safari.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
yjbanov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | ||
|
|
||
| _initializeEditableElement(); | ||
| activeEditableElement.style.transform = 'translate(-999px,-999px)'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With 8k screen resolutions getting to 7680x4320 these days, I wonder if 999 is a sufficient #offset. Would using a bigger number, e.g. 20000, work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I've increased it to 9999 to match what we have in the non semantic iOS strategy.
961791d to
0514a21
Compare
* 5aee791 Roll Dart SDK from 645fd748e79e to 0097dcbada06 (3 revisions) (flutter/engine#38883) * 78a68b9 Roll Skia from c64a10d525d1 to aa99fa0bdd31 (10 revisions) (flutter/engine#38886) * 398af8c Roll Fuchsia Mac SDK from w0hr1ZMvYGJnWInwK... to nPbEqgIfE8TLOokQH... (flutter/engine#38889) * 7035027 Roll Skia from aa99fa0bdd31 to 5a51583d09dd (2 revisions) (flutter/engine#38892) * 2075cf3 Roll Fuchsia Mac SDK from nPbEqgIfE8TLOokQH... to SmEVvAFBC8oriPBou... (flutter/engine#38897) * ef06ef6 Roll Skia from 5a51583d09dd to 34a14247bd4b (1 revision) (flutter/engine#38901) * 0d374a9 Roll Skia from 34a14247bd4b to c727016cc09e (1 revision) (flutter/engine#38903) * 31f2020 Roll Skia from c727016cc09e to 214411b09e92 (2 revisions) (flutter/engine#38907) * a3006de Bump actions/setup-python from 4.4.0 to 4.5.0 (flutter/engine#38909) * eacc09c Bump github/codeql-action from 2.1.37 to 2.1.38 (flutter/engine#38910) * c33c11c Roll Skia from 214411b09e92 to 3704033dd106 (1 revision) (flutter/engine#38908) * afa093d [Impeller] Map UVs correctly for TiledTextureContents (flutter/engine#38894) * 46ea2b3 Roll Fuchsia Mac SDK from SmEVvAFBC8oriPBou... to bZfX8KCoI3CfxEzsG... (flutter/engine#38912) * aadb971 Roll Skia from 3704033dd106 to 58e745419425 (4 revisions) (flutter/engine#38936) * 24b21a5 Roll Fuchsia Mac SDK from bZfX8KCoI3CfxEzsG... to iwCuzAuMgsk75hlT0... (flutter/engine#38938) * e655580 Roll Skia from 58e745419425 to 6afb97022fa7 (1 revision) (flutter/engine#38943) * 5932bad Revert "Revert "[web] Don't overwrite editing state with semantic updates (#38271)" (#38562)" (flutter/engine#38854) * 928772e [web] Reduce code size impact of fallback font data (flutter/engine#38787) * 88a8d9a Roll Skia from 6afb97022fa7 to 8ea9b39f7213 (18 revisions) (flutter/engine#38952) * 3a47943 Roll Skia from 8ea9b39f7213 to 69d8378097df (6 revisions) (flutter/engine#38953) * 641623a wrap focus() in a post update callback (flutter/engine#38958) * 7d71ee3 Roll Fuchsia Mac SDK from iwCuzAuMgsk75hlT0... to -1N2YUML8GqNhK8YP... (flutter/engine#38960) * d762142 reland fix canvas drawLine bugs (flutter/engine#38949) * 0d79533 [Impeller] Fix back-to-back clip restoration (flutter/engine#38964) * 19fe86c Update scenario screenshots to iOS 16 (flutter/engine#38962) * eb18ac0 Fix iOS safari keyboard issue when semantics is enabled (flutter/engine#38822) * 84a73d9 [Impeller Scene] Add SceneNodeValue for synchronously fetching loaded ipscenes (flutter/engine#38913) * 7bff5dd Revert "Roll Dart SDK from 645fd748e79e to 0097dcbada06 (3 revisions) (#38883)" (flutter/engine#38973) * c52b290 Roll Fuchsia Mac SDK from -1N2YUML8GqNhK8YP... to P5QcCJU8I71xVXuMT... (flutter/engine#38976)
…18720) * 5aee791 Roll Dart SDK from 645fd748e79e to 0097dcbada06 (3 revisions) (flutter/engine#38883) * 78a68b9 Roll Skia from c64a10d525d1 to aa99fa0bdd31 (10 revisions) (flutter/engine#38886) * 398af8c Roll Fuchsia Mac SDK from w0hr1ZMvYGJnWInwK... to nPbEqgIfE8TLOokQH... (flutter/engine#38889) * 7035027 Roll Skia from aa99fa0bdd31 to 5a51583d09dd (2 revisions) (flutter/engine#38892) * 2075cf3 Roll Fuchsia Mac SDK from nPbEqgIfE8TLOokQH... to SmEVvAFBC8oriPBou... (flutter/engine#38897) * ef06ef6 Roll Skia from 5a51583d09dd to 34a14247bd4b (1 revision) (flutter/engine#38901) * 0d374a9 Roll Skia from 34a14247bd4b to c727016cc09e (1 revision) (flutter/engine#38903) * 31f2020 Roll Skia from c727016cc09e to 214411b09e92 (2 revisions) (flutter/engine#38907) * a3006de Bump actions/setup-python from 4.4.0 to 4.5.0 (flutter/engine#38909) * eacc09c Bump github/codeql-action from 2.1.37 to 2.1.38 (flutter/engine#38910) * c33c11c Roll Skia from 214411b09e92 to 3704033dd106 (1 revision) (flutter/engine#38908) * afa093d [Impeller] Map UVs correctly for TiledTextureContents (flutter/engine#38894) * 46ea2b3 Roll Fuchsia Mac SDK from SmEVvAFBC8oriPBou... to bZfX8KCoI3CfxEzsG... (flutter/engine#38912) * aadb971 Roll Skia from 3704033dd106 to 58e745419425 (4 revisions) (flutter/engine#38936) * 24b21a5 Roll Fuchsia Mac SDK from bZfX8KCoI3CfxEzsG... to iwCuzAuMgsk75hlT0... (flutter/engine#38938) * e655580 Roll Skia from 58e745419425 to 6afb97022fa7 (1 revision) (flutter/engine#38943) * 5932bad Revert "Revert "[web] Don't overwrite editing state with semantic updates (flutter#38271)" (flutter#38562)" (flutter/engine#38854) * 928772e [web] Reduce code size impact of fallback font data (flutter/engine#38787) * 88a8d9a Roll Skia from 6afb97022fa7 to 8ea9b39f7213 (18 revisions) (flutter/engine#38952) * 3a47943 Roll Skia from 8ea9b39f7213 to 69d8378097df (6 revisions) (flutter/engine#38953) * 641623a wrap focus() in a post update callback (flutter/engine#38958) * 7d71ee3 Roll Fuchsia Mac SDK from iwCuzAuMgsk75hlT0... to -1N2YUML8GqNhK8YP... (flutter/engine#38960) * d762142 reland fix canvas drawLine bugs (flutter/engine#38949) * 0d79533 [Impeller] Fix back-to-back clip restoration (flutter/engine#38964) * 19fe86c Update scenario screenshots to iOS 16 (flutter/engine#38962) * eb18ac0 Fix iOS safari keyboard issue when semantics is enabled (flutter/engine#38822) * 84a73d9 [Impeller Scene] Add SceneNodeValue for synchronously fetching loaded ipscenes (flutter/engine#38913) * 7bff5dd Revert "Roll Dart SDK from 645fd748e79e to 0097dcbada06 (3 revisions) (flutter#38883)" (flutter/engine#38973) * c52b290 Roll Fuchsia Mac SDK from -1N2YUML8GqNhK8YP... to P5QcCJU8I71xVXuMT... (flutter/engine#38976)
* Update branch with changes in main - Fix iOS safari keyboard issue when semantics is enabled * Update branch with main - small enhancements * set offset to -9999px instead of -999 * Add editing state tests to ios * replace editableElement with the null checked one

Fixes flutter/flutter#110284
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.