Do not move focus when the semantics text strategy is deactivated.#54979
Do not move focus when the semantics text strategy is deactivated.#54979tugorez wants to merge 2 commits intoflutter:mainfrom
Conversation
| // Keep this consistent with how DefaultTextEditingStrategy does it. As of | ||
| // right now, the only difference is that semantic text fields do not | ||
| // participate in form autofill. | ||
| DefaultTextEditingStrategy.scheduleFocusFlutterView(activeDomElement, activeDomElementView); |
There was a problem hiding this comment.
TextEditingStrategy.disable is used by TextInput.clearClient, TextInput.hide, and in one case by TextInput.setClient. The focus move (which previously was just domElement.blur()) seems to have the intention to close the virtual keyboard when the framework demands it. If we do not do anything here, does it mean that there are situations when the framework would detach and move onto the next widget, but the browser will stay focused on the text field and virtual keyboard showing? I remember we had bugs where the virtual keyboard would show up, but typing into it would not enter any text, because the <input> is not connected to the framework.
There was a problem hiding this comment.
That's a great point Yegor!
If I understand correctly, the deactivated call suggests either app transitioned "flutter" focus to another widget, shifting the "browser" focus, or the user interacted outside the app, causing it to lose focus. In both cases the focus will be moved away from the text input causing the keyboard to be hidding. Is there a use case I might be missing?
When the text field is deactivated, the non-semantics text strategy refocuses on the Flutter view. This is necessary because there's no assurance that the next interactive widget will be supported by a DOM node. If not, focus will shift outside the Flutter view. With semantics enabled, the app ensures every interactive widget has a corresponding DOM node, eliminating the need to refocus on the Flutter view. In fact, the view shouldn't be focusable with semantics enabled to avoid disrupting the interaction sequence.
This PR should be the last step before landing #54966
I compiled https://github.com/flutter/flutter/tree/master/dev/a11y_assessments with these changes. App can be found at https://tugorez.com/flutter_focus_web/
flutter/flutter#153022
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.