Repository navigation
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. While there are exceptions to this rule, if this patch modifies code it is probably not an exception. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
6c4b13b to
a38b629
Compare
|
@justinmc Do you still have plans for this PR? |
|
Yes, but it seems like I haven't gotten back to this in a long time! I'll close it for now and make a note to myself to reopen when I have time to work on it. |
|
SOLUTION Here's the solution for a suffix or prefix taps |
|
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Description
In both Material and Cupertino, taps on a prefix or suffix in a text field are received by the text field itself as well as the prefix/suffix. This causes unexpected behavior when a button is in the prefix/suffix or even exceptions when clearing text.
The root cause of this problem is TextSelectionGestureDetector, which allows listening to all events, not just events given to it by the gesture arena. This is necessary, however, because it needs to listen to gestures that happen on top of the selection handles.
Cupertino Solution
CupertinoTextField already solves this problem for its built-in clear button. It uses a GlobalKey to check if a tap hits the clear button and ignores the tap if so. I've taken the same approach to solve this for prefix/suffix.
I added two parameters to enable this solution. Here is a typical use case:
Read more in the code and docs here.
Material Solution
This is still a work in progress. I'm trying to take the same approach, but
prefixandsuffixare passed into InputDecoration, so I can't directly give them GlobalKeys and access them in TextField's TextSelectionGestureDetector. I'm trying to work around that.Related Issues
#36324
#39376
Closes #39376
Tests
TODO