Skip to content

Resizing the mat-option with height and line-height for the mat-autocomplete alters the autocomplete keyboard scrolling #10038

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

Closed
oscarlagatta opened this issue Feb 20, 2018 · 12 comments

Comments

@oscarlagatta
Copy link

Bug, feature request, or proposal:

Once the .mat-option class height and line-height have been modified the keyboard scrolling looses focus of the active option

What is the expected behavior?

the autocomplete results should scroll with the keyboard active item selected

What is the current behavior?

if the size of the .mat-option is modified the autocomplete scrolling loses the active option selected by the keyboard arrow (up/down)

What are the steps to reproduce?

Providing a StackBlitz reproduction is the best way to share your issue.

StackBlitz starter: https://goo.gl/wwnhMV

apply the following css styling

.mat-autocomplete-panel {
max-height: 455px !important;
}
.mat-option {
height: 25px !important;
line-height: 25px !important;
}

What is the use-case or motivation for changing an existing behavior?

to behave as expected while scrolling with the keyboard

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

"@angular/core": "^5.0.0",
"@angular/material": "^5.2.1",
WINDOWS
Typescript 2.7.1
Chrome Version 63.0.3239.84 (Official Build) (64-bit)

Is there anything else we should know?

@crisbeto
Copy link
Member

Duplicate of #7211 (mat-select and mat-autocomplete use the same option component).

@oscarlagatta
Copy link
Author

Thanks I don’t see how one is related to the other, can you pls explain ?

@crisbeto
Copy link
Member

We currently assume that all options will have a particular height, which is why we have to truncate them as well. Your issue comes from the fact that you're overriding the height.

@oscarlagatta
Copy link
Author

oscarlagatta commented Feb 20, 2018 via email

@DMezhenskyi
Copy link
Contributor

DMezhenskyi commented Apr 25, 2018

@crisbeto Hi! Could you please clarify what the reason to hardcode the height of mat-option component? Why it isn't possible to calculate height once a mat-option was rendered and then to use this value to calculate a correct scrollTop? Or even better - to be able to define mat-option height as @ Input() of MatAutocomplete or MatSelect ? Thanks

@supersinex
Copy link

I would also love a fix for this. Some of our autocompletes are composed of two or more lines of information, so the ability to change the height of the mat-option while maintaining the ability to navigate with the arrow keys would be great.

@noririco
Copy link

This issue is so annoying, And how the hell do you change the
AUTOCOMPLETE_OPTION_HEIGHT
no docs no nothing ;/

@Sahil624
Copy link

Sahil624 commented May 29, 2019

I think option height and autocomplete height should be configurable. Or there should be a dense view. (My use case)

@mohamed-badaoui
Copy link

RIght now, the only way to overcome this is probably to add some global main style, like this :(

.mat-autocomplete-panel mat-option {
height: 25px;
}

@deepthir9977
Copy link

Hi guys,
i am using mat autocomplete i had Resizing the mat-option with height and line-height for the mat-autocomplete like below
.mat-autocomplete-panel mat-option {
height: 25px;
}
i am not able to see the highlighted option on arrow key down.
is there any solution please help.

@Sahil624
Copy link

Sahil624 commented Jul 9, 2019

Hi guys,
i am using mat autocomplete i had Resizing the mat-option with height and line-height for the mat-autocomplete like below
.mat-autocomplete-panel mat-option {
height: 25px;
}
i am not able to see the highlighted option on arrow key down.
is there any solution please help.

I think height of autocomplete and mat-option is constant , so when you scroll with keys it will only scroll when that constant height is breached (I'm not 100% sure but I think it works like this). When you define height globally It only changes the height but not the constants hardcoded. I had same issue I fixed it with some rxjs but it created some new issues, so I reset global styles and used default styles by angular.

I don't think that there is any workaround. But if anyone knows any please comment

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants