Skip to content
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

feat(mat-select): The selected option shows at the bottom when opening. Make this position configurable. #28225

Open
Bschitter opened this issue Dec 4, 2023 · 3 comments
Labels
area: material/select feature This issue represents a new feature or feature request rather than a bug or bug fix needs: clarification The issue does not contain enough information for the team to determine if it is a real bug P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@Bschitter
Copy link

Feature Description

Version: Angular Material 17.0.2

Description

When I have a mat-select with many options, the selected value will always be at the bottom when opening the mat-select.

image

Suggestion

Make where the selected option shows configurable with values like bottom (default) | middle | top as shown in the screenshot below.

image

Use Case

For some use cases, it might be better to have the selected option at the top or in the middle, so the previous resp. the previous and next values can be seen.
E.g. the select list is sorted and I'm iterating through the select (for whatever reason) then I always have to scroll when I want to select the next item.

@Bschitter Bschitter added feature This issue represents a new feature or feature request rather than a bug or bug fix needs triage This issue needs to be triaged by the team labels Dec 4, 2023
@andrewseguin andrewseguin added needs: clarification The issue does not contain enough information for the team to determine if it is a real bug area: material/select P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed needs triage This issue needs to be triaged by the team labels Jan 29, 2024
@andrewseguin
Copy link
Contributor

Can you add a reproduction of this issue? I don't understand why the selection is always at the bottom. That doesn't sound right

@Bschitter
Copy link
Author

You can take the examples from the docs, e.g. Select with reset option from https://material.angular.io/components/select/examples

Then select a state where you need to scroll down (from Colorado onwards), e.g. Maine.
Then open it again and you will see that Maine is at the bottom.

Happens in Firefox 122.0 and Chrome 121.0.6167.139

@nora-alphbrk
Copy link

I'd also be happy to see this implemented. For us, the use case is that we are building a time selection with start and end times, and we are aiming at providing the same user experience as the Google Calendar where a value is preselected and the selected value is then displayed in the middle of the option list. Like so:

Screen.Recording.2024-05-10.at.11.54.40.mov

I tried to achieve this with scrollIntoView for the selected option in the select's opened handler, but we are not happy with this solution because it creates a jumping behavior as the "scroll" is clearly visible. It looks odd. (We tried both scrolling behaviors instant and smooth and none of those are acceptable for us, unfortunately.)

A config option as suggested by @Bschitter would be great so that the position is set immediately when the select is opened (as visible in the Google Calendar recording).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: material/select feature This issue represents a new feature or feature request rather than a bug or bug fix needs: clarification The issue does not contain enough information for the team to determine if it is a real bug P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
3 participants