-
-
Couldn't load subscription status.
- Fork 1.5k
MudAutocomplete: Scroll to selected item when not strict #11049
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
MudAutocomplete: Scroll to selected item when not strict #11049
Conversation
Match behavior to MudSelect
|
I'm not sure that this would be enough. Remember that the AutoComplete, by default, shows only the first 10 items. So, if the user selects the 12th item in the list by typing, when they re-open the list the selected item won't be rendered in the initial 10 items meaning it can't be scrolled to. |
|
@Anu6is Very true I will need to adjust this. I have all my autocompletes with null for max items. Thanks |
Add logic to account for MaxItems being not null
Account for MaxItems > total # of items
|
I will fix the current failing tests and add test(s) for the new functionality but first I would appreciate feedback before I do that. Do we want to be able to toggle on/off this functionality? I can see some not wanting this, but I think it should be on be default because that is the way MudSelect works. |
|
Sorry for the pings but I'd like feedback before continuing to work on this. @henon @danielchalmers @versile2 Thank you for your time :) |
|
I can't speak for others but I like auto scrolling to it and I don't see a need to add yet another option. There's no harm in it and I can't think of a scenario where scrolling automatically to the selected item would cause an issue. I do know there is a pending PR to fix some functionality so I would wait until that is merged then pull it into this one before continuing. Ultimately the decision falls to others but that is my opinion. V |
|
I am for adding this too. I would even go so far as to call the current behavior a bug. |
|
Good thinking about compatibility concerns, but I agree this is a bug and can be fixed without any extra steps |
New scroll to logic now shows different items/different item indexes depending on what is searched for. Changed tests to now correctly find indexes/expected items.
Combine if statement
|
Thank you all for the feedback @Anu6is @versile2 @henon @danielchalmers Fixed the failing tests and the SonarQube Major issue, but could use some help on:
All done besides any action on the above 2 points |
|
|
Are you able to update the spacing issues and what not? |
Yes, will be able to do the last steps this week. |
Awesome, I think this is a value bug fix, hit me up on Discord dm if you have any questions. V |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #11049 +/- ##
=======================================
Coverage 91.10% 91.10%
=======================================
Files 465 465
Lines 14407 14407
Branches 2788 2788
=======================================
Hits 13126 13126
Misses 642 642
Partials 639 639 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Fix whitespace errors
fix whitespace errors

Now when
strictisfalsethe selected item will be scrolled to when opening the Autocomplete.Description
When selecting an item with strict set to false, then clicking the Autocomplete the list would just open to the first item. This behavior is the opposite of what MudSelect does. This PR matches the behavior and will scroll to selected item.
Do we want to add a bool parameter that turns the auto scroll on/off?
(You can compare the current behavior: select an item, then reopen the select/autocomplete)
https://www.mudblazor.com/components/select#visual-playground
https://www.mudblazor.com/components/autocomplete#strict-mode
How Has This Been Tested?
Visually tested with current tests passing.
Type of Changes
Could be a breaking change if user implemented custom scroll logic?
Before:


After:
Checklist
dev).