[web] Fix framework material text field tests #25367
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR does two things, to fix material text field tests in the framework:
1. Handling clicks above/below the paragraph
When a click is received above the paragraph, we used to return the beginning of the paragraph as the result position. But Flutter does this slightly differently.
Example: for the string "Lorem ipsum", if the user clicks between "i" and "p", the cursor is placed between "i" and "p". This has always been fine. But if the user clicks between "i" and "p" on the X axis, but above the text on the Y axis, the web engine used to place the cursor at the beginning of the paragraph (at position 0). This will now be fixed so it places the cursor between "i" and "p".
2. Assertions
The assertion in the
extendTo
method was supposed to help catch mistake in the layout algorithm. But so far it has caused more harm than good. So I'm removing it instead of adding more and more edge cases to it.Related issue: flutter/flutter#79070