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

Conversation

@mdebbar
Copy link
Contributor

@mdebbar mdebbar commented Feb 29, 2024

Handle viewId for text fields.

Part of flutter/flutter#137344

@mdebbar mdebbar requested a review from ditman February 29, 2024 21:33
@github-actions github-actions bot added the platform-web Code specifically for the web engine label Feb 29, 2024
@mdebbar
Copy link
Contributor Author

mdebbar commented Mar 11, 2024

Still working on auto-fill tests, but I would appreciate a review of the code!

Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

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

This looks great!

Left a couple of comments with DOM APIs that might simplify some of our code here, but in general this is sweet!

@mdebbar mdebbar requested a review from ditman March 14, 2024 14:26
Copy link
Member

@ditman ditman left a comment

Choose a reason for hiding this comment

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

Not a big fan of the looping to find the hostElement of the view to which an element belongs, but IMO not a blocker. LGTM!

Comment on lines 170 to 174
if (view == null) {
// `viewId` points to a non-existent view, is this even possible? Should we
// throw?
return;
}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe convert this in one of those assert(viewId != null, 'This should never happen, create a bug!');, rather than bailing out silently?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment on lines 112 to 113
while (current != null) {
final EngineFlutterView? view = _elementToView[current];
Copy link
Member

Choose a reason for hiding this comment

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

Why this while and not closest? Is iterating our own cache faster than a brower querySelector/closest?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't like the idea of depending on tag name and html attributes. But I'm not feeling strongly about it, so I'll switch to closest since it might be faster.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@ditman
Copy link
Member

ditman commented Mar 27, 2024

Safari seems unhappy with the change, a couple of these:

00:08 +298 ~7 -1: text_editing_test.dart: HybridTextEditing inserts element in the correct view [E]
  Expected: true
    Actual: <false>

final DomElement input = textEditing!.strategy.domElement!;

// Input is appended to the right view.
expect(view.dom.textEditingHost.contains(input), isTrue);
Copy link
Member

Choose a reason for hiding this comment

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

(I think this is the line that safari doesn't like?)

One way of making the text more readable is to add a reason: 'input must be contained in textEditingHost' or similar, so the test failure has some meaning (rather than: "expected true but got false")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. This is because on Safari we do some shady stuff haha. I updated the test to properly work on Safari.

auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Mar 28, 2024
In order for text fields to work correctly in multi-view on the web, we need to have the `viewId` information sent to the engine (`TextInput.setClient`). And while the text field is active, if it somehow moves to a new `View`, we need to inform the engine about such change (`TextInput.updateConfig`).

Engine PR: flutter/engine#51099
Fixes #137344
philipfranchi pushed a commit to philipfranchi/flutter-relabel-widgets that referenced this pull request Mar 28, 2024
In order for text fields to work correctly in multi-view on the web, we need to have the `viewId` information sent to the engine (`TextInput.setClient`). And while the text field is active, if it somehow moves to a new `View`, we need to inform the engine about such change (`TextInput.updateConfig`).

Engine PR: flutter/engine#51099
Fixes flutter#137344
@mdebbar mdebbar added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 29, 2024
@auto-submit auto-submit bot merged commit 79f1530 into flutter:main Mar 29, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 29, 2024
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Mar 29, 2024
@mdebbar mdebbar deleted the text_editing_view_id branch April 18, 2024 15:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App platform-web Code specifically for the web engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants