-
Notifications
You must be signed in to change notification settings - Fork 29.7k
fix: Dropdown menu trying to access highlight element which doesn't exist when search and filters both are enabled #151969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
8f2ee49 to
a5109c9
Compare
828ec84 to
b4a1f79
Compare
| if (searchText.isEmpty || entries.isEmpty) { | ||
| return null; | ||
| } | ||
| if (currentHighlight != null && entries[currentHighlight!].label.toLowerCase().contains(searchText)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is still possible to have out of range error when entries reduce in size but still non-empty.
For example, highlight the second item, then enter a search that only matches a single item would cause out of range error in entries[currentHighlight!].
6942bf6 to
c997c14
Compare
bleroux
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution.
Moving the new test just after the last one introduced in #147294 would make sense.
| expect(textField.keyboardType, TextInputType.text); | ||
| }); | ||
|
|
||
| // Regression test for https://github.com/flutter/flutter/issues/151878 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Regression test for https://github.com/flutter/flutter/issues/151878 | |
| // Regression test for https://github.com/flutter/flutter/issues/151878. |
| ), | ||
| )); | ||
|
|
||
| // Open the menu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Open the menu | |
| // Open the menu. |
20afbe2 to
77bc9f1
Compare
|
Sorry for the inconvenience. I think I've made a mistake in #147294. The checking of current selection should not be put in After some further reading of the original code, I think |
0e678ee to
5c65cde
Compare
QuncCccccc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the contribution! Seems there are still some test failures. Could you help take a look:)?
| } else { | ||
| currentHighlight = search(filteredEntries, _localTextEditingController!); | ||
| final bool shouldUpdateCurrentHighlight = _shouldUpdateCurrentHighlight(filteredEntries, _localTextEditingController!); | ||
| if(shouldUpdateCurrentHighlight){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if(shouldUpdateCurrentHighlight){ | |
| if (shouldUpdateCurrentHighlight){ |
2091d43 to
dd453ca
Compare
|
@PurplePolyhedron Does this PR conflict with your work on #152378? |
Yes, there are some conflicts, #152378 removed the |
dd453ca to
56f32e4
Compare
|
@rkishan516 has the conflict with #152378 been resolved? Asking if this is ready for another review. :) |
No, @Piinks, I am waiting for #152378 to merged and based on that I will do required changes. |
|
Ah ok! Thank you very much for clarifying. We'll follow up on this once #152378 lands. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to no longer change the search function in #152378 (Pending review). There shouldn't be conflict any more.
Apologies for troubles.
| currentHighlight = widget.searchCallback!(filteredEntries, _localTextEditingController!.text); | ||
| } else { | ||
| currentHighlight = search(filteredEntries, _localTextEditingController!); | ||
| final bool shouldUpdateCurrentHighlight = _shouldUpdateCurrentHighlight(filteredEntries, _localTextEditingController!); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't use shouldUpdateCurrentHighlight when a searchCallback is provided, since we don't know its match condition.
66dad07 to
cda835c
Compare
cda835c to
b6bbbe9
Compare
|
Please let me know once this is ready to review:) Once the PR comments above are addressed and get the second approval, we are good to go! |
1ed211f to
8b2bfda
Compare
I have changed things other than the test bit. |
Can you try to run the test on the newest version without |
8b2bfda to
cbfedbc
Compare
|
@rkishan516 Looking at the new diff, it looks like you applied autoformat to |
…xist when search and filters are enabled
cbfedbc to
265a349
Compare
Hey @bleroux, Sorry for that. I have fixed and pushed the change. |
No worry, every contributor hit this at one point 😅 |
QuncCccccc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM:) Thanks for the contribution! Once we have the second approval, we are good to go!
bleroux
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
…oesn't exist when search and filters both are enabled (flutter/flutter#151969)
…oesn't exist when search and filters both are enabled (flutter/flutter#151969)
…oesn't exist when search and filters both are enabled (flutter/flutter#151969)
…oesn't exist when search and filters both are enabled (flutter/flutter#151969)
…oesn't exist when search and filters both are enabled (flutter/flutter#151969)
Roll Flutter from 2e221e7 to 303f222 (77 revisions) flutter/flutter@2e221e7...303f222 2024-09-12 [email protected] Manual roll to 48ddaf578fb0c8326d5b4b680b0f49ea72e33216 (flutter/flutter#155070) 2024-09-12 [email protected] Externalize and update onboarding instructions (flutter/flutter#154730) 2024-09-12 [email protected] when setting up the log reader for a device during `flutter run`, discard any `RPCError` thrown due to the device being disconnected (flutter/flutter#155049) 2024-09-12 98614782+auto-submit[bot]@users.noreply.github.com Reverts "iOS: update provisioning profile for 2024-2025 cert (#155052)" (flutter/flutter#155059) 2024-09-12 [email protected] iOS: update provisioning profile for 2024-2025 cert (flutter/flutter#155052) 2024-09-11 [email protected] Factor out `Container` objects (flutter/flutter#153619) 2024-09-11 [email protected] Move (`dev/tools`), complete v0 of `native_driver` (Android) (flutter/flutter#154843) 2024-09-11 [email protected] Roll Flutter Engine from ade8ef293bc6 to ee5adf6d2ee1 (2 revisions) (flutter/flutter#155046) 2024-09-11 [email protected] Fix `flutter run` on Mac x64 hosts if Swift Package Manager is enabled (flutter/flutter#154645) 2024-09-11 [email protected] Roll Packages from bb53e5d to 4c18648 (1 revision) (flutter/flutter#155033) 2024-09-11 [email protected] Roll Flutter Engine from 4eb729b7a5c4 to ade8ef293bc6 (3 revisions) (flutter/flutter#155031) 2024-09-11 [email protected] fix: Dropdown menu trying to access highlight element which doesn't exist when search and filters both are enabled (flutter/flutter#151969) 2024-09-11 [email protected] Marks Linux build_tests_3_5 to be unflaky (flutter/flutter#154993) 2024-09-11 [email protected] Add 'direction' allow to 'SegmentedButton' oriented vertically (flutter/flutter#150903) 2024-09-11 [email protected] Marks Linux build_tests_5_5 to be unflaky (flutter/flutter#154995) 2024-09-11 [email protected] Update the signature of DDS launcher callback. (flutter/flutter#154949) 2024-09-11 [email protected] Migrate Color.toString() test, improves `equalsIgnoringHashCodes` (flutter/flutter#154934) 2024-09-11 [email protected] Update material and cupertino localizations (flutter/flutter#154959) 2024-09-11 [email protected] Marks Linux build_tests_1_5 to be unflaky (flutter/flutter#154991) 2024-09-11 [email protected] Marks Linux build_tests_2_5 to be unflaky (flutter/flutter#154992) 2024-09-11 [email protected] Fix `flutter create` warning regarding Java compatibility (flutter/flutter#152836) 2024-09-11 [email protected] Roll Flutter Engine from 54757dab9462 to 4eb729b7a5c4 (1 revision) (flutter/flutter#155022) 2024-09-11 [email protected] Fix java version used by `build_aar_module_test` (flutter/flutter#154967) 2024-09-11 [email protected] Roll Flutter Engine from 0a14c519ea4f to 54757dab9462 (1 revision) (flutter/flutter#155015) 2024-09-11 [email protected] Roll Flutter Engine from 35a3171b72c5 to 0a14c519ea4f (1 revision) (flutter/flutter#154984) 2024-09-11 [email protected] Roll Flutter Engine from b9c0b96c3316 to 35a3171b72c5 (1 revision) (flutter/flutter#154980) 2024-09-11 [email protected] Roll Flutter Engine from 52eeea075767 to b9c0b96c3316 (1 revision) (flutter/flutter#154976) 2024-09-11 [email protected] Roll Flutter Engine from a26075f9b1e6 to 52eeea075767 (1 revision) (flutter/flutter#154973) 2024-09-11 [email protected] Roll Flutter Engine from 60c15bc0f40e to a26075f9b1e6 (6 revisions) (flutter/flutter#154969) 2024-09-11 [email protected] Migrate `apple-mobile-web-*` to `mobile-web-*`. (flutter/flutter#154964) 2024-09-11 [email protected] Roll Flutter Engine from 8a038a6f7099 to 60c15bc0f40e (15 revisions) (flutter/flutter#154960) 2024-09-10 [email protected] Adds dart fixes for Color opacity functions (flutter/flutter#154953) 2024-09-10 [email protected] Missing benchmarks for `foundation/all_elements_bench.dart` (flutter/flutter#154954) 2024-09-10 [email protected] Update color assertions (flutter/flutter#154752) 2024-09-10 [email protected] handle EAGAIN (macOS) in ErrorHandlingProcessManager (flutter/flutter#154306) 2024-09-10 [email protected] fix unpack freezing app with animation duration zero (flutter/flutter#153890) 2024-09-10 [email protected] Remove last `--disable-dart-dev` in `flutter/flutter`. (flutter/flutter#154948) 2024-09-10 [email protected] Remove scheduler: luci from new `build_aar_module_test` (flutter/flutter#154945) 2024-09-10 [email protected] Roll pub packages (flutter/flutter#154939) 2024-09-10 [email protected] `CupertinoSlidingSegmentedControl` update (flutter/flutter#152976) 2024-09-10 [email protected] Roll pub packages (flutter/flutter#154933) 2024-09-10 [email protected] fix test `chrome.close can recover if getTab throws a StateError` (flutter/flutter#154889) 2024-09-10 [email protected] SearchBar context menu (flutter/flutter#154833) 2024-09-10 [email protected] Fix `flutter build aar` for modules that use a plugin (flutter/flutter#154757) 2024-09-10 [email protected] Roll Packages from b4e0fc1 to bb53e5d (4 revisions) (flutter/flutter#154926) 2024-09-10 [email protected] Clean up `SnackBar` inherit theme data test (flutter/flutter#154921) ...
…oesn't exist when search and filters both are enabled (flutter/flutter#151969)
…oesn't exist when search and filters both are enabled (flutter/flutter#151969)
DropdownMenu throws RangeError when both filter and search are enabled because when we search for elements, we have some highlighted element, but if there is no element to highlight it tries to access 0th element is the filtered entries, but entries are empty.
Fixes #151878
Pre-launch Checklist
///).