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

fix(cdk/listbox): scroll active option into view when using aria-activedescendant #29722

Merged
merged 1 commit into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/cdk/listbox/listbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,13 @@ export class CdkOption<T = unknown> implements ListKeyManagerOption, Highlightab
* No-op implemented as a part of `Highlightable`.
* @docs-private
*/
setActiveStyles() {}
setActiveStyles() {
// If the listbox is using `aria-activedescendant` the option won't have focus so the
// browser won't scroll them into view automatically so we need to do it ourselves.
if (this.listbox.useActiveDescendant) {
this.element.scrollIntoView({block: 'nearest', inline: 'nearest'});
}
}

/**
* No-op implemented as a part of `Highlightable`.
Expand Down
Loading