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

[BUG] scrolling using Page Up and Home does not scroll all the way to the top #421

Open
paulflo150 opened this issue Feb 21, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@paulflo150
Copy link

Describe the bug
Using Home or Page Up to scroll does not seem to take into consideration the sticky element, so it will only scroll to the top of the actual list of options, which leaves the very first element of the list hidden under the search. Any ideas on how to get this fixed?

To Reproduce
You can see it in the example provided.

@paulflo150 paulflo150 added the bug Something isn't working label Feb 21, 2023
@macjohnny
Copy link
Member

thanks for reporting this issue. do you want to try to find a fix?

@paulflo150
Copy link
Author

paulflo150 commented Feb 21, 2023

How about something like this?

`
_handleKeydown(event: KeyboardEvent) {
//existing code.

if (event.key === 'PageUp' || event.key === 'PageDown') {
  const panel = this.matSelect.panel.nativeElement;

  const left = panel.scrollLeft;
  const top = panel.scrollTop;

  const delta = panel.scrollHeight - 32 * 5;

  event.key === 'PageUp' ? panel.scrollTo(left, top - delta) : panel.scrollTo(left, top + delta);
  
  event.preventDefault();
}

if (event.key === 'Home' || event.key === 'End') {
  const panel = this.matSelect.panel.nativeElement;
  event.key === 'Home' ? panel.scrollTo(0, 0) : panel.scrollTo(0, panel.scrollHeight);

  event.preventDefault();
}

}
`

@macjohnny
Copy link
Member

I havent tested that, but do you want to create a PR and test that this works properly?

@macjohnny
Copy link
Member

@paulflo150 would you like to prepare a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants