Repository navigation
Fix DropdownMenu throwing TextEditingController disposed error on select (#139266) - #139268
josh-burton wants to merge 2 commits into
Conversation
…n when DropdownMenu item is selected
|
Unfortunately, this won't work because I used your tests, I hope you don't mind. (If you do mind, I'm also happy to write my own). See #139385 |
No problem, thank you! |
… select (#139385) ## Description When a DropdownMenu exists within another menu and a MenuItem is selected, the `TextEditingController` of the DropdownMenu is used after it has been disposed. This PR manages the local `TextController` instance better, making sure that the one used when building is the current one, and handling the case where the `controller` is set on the widget after initial creation. Also, places where we were setting the text and selection separately were converted to use `TextEditingValue` and set the value atomically. ## Related Issues - Fixes #139266 ## Tests - Added tests (Created by @josh-burton in #139268 - Thanks Josh!)
… select (#139385) ## Description When a DropdownMenu exists within another menu and a MenuItem is selected, the `TextEditingController` of the DropdownMenu is used after it has been disposed. This PR manages the local `TextController` instance better, making sure that the one used when building is the current one, and handling the case where the `controller` is set on the widget after initial creation. Also, places where we were setting the text and selection separately were converted to use `TextEditingValue` and set the value atomically. ## Related Issues - Fixes flutter/flutter#139266 ## Tests - Added tests (Created by @josh-burton in flutter/flutter#139268 - Thanks Josh!)
When a DropdownMenu exists within another menu and a MenuItem is selected, the TextEditingController of the DropdownMenu is used after it has been disposed.
This PR checks whether the controller has been disposed before using it in the onPressed callback.
Note I'm not sure whether the
hasListenersmethod is the correct way to check if the textEditingController is disposed.Fixes #139266
List which issues are fixed by this PR. You must list at least one issue. An issue is not required if the PR fixes something trivial like a typo.
If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on [Discord].