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

Dropdown: Keyboard navigation not working when encapsulated in shadow DOM #4540

Closed
nextgovitAS opened this issue Jul 17, 2023 · 1 comment · Fixed by #4548
Closed

Dropdown: Keyboard navigation not working when encapsulated in shadow DOM #4540

nextgovitAS opened this issue Jul 17, 2023 · 1 comment · Fixed by #4548

Comments

@nextgovitAS
Copy link

Description:

The dropdown menu of the dropdown component cannot be navigated properly with the arrow keys when the component is used within a component with encapsulation: ViewEncapsulation.ShadowDom.

StackBlitz:

https://stackblitz.com/edit/angular-1fdepu?file=src%2Fapp%2Fdropdown-basic.ts

Versions

Angular: v16.1
ng-bootstrap: v15.1
Bootstrap: v5.2.3

@maxokorokov
Copy link
Member

maxokorokov commented Jul 23, 2023

Looks like activeElement points to the shadow root (ngbd-dropdown-basic component), not the actual item in this case:

if (item === this._document.activeElement) {
position = index;
}

Should be this._document.activeElement.shadowRoot.activeElement:

https://developer.mozilla.org/en-US/docs/Web/API/ShadowRoot/activeElement

So we actually might need something like getActiveElement() utility I guess.

FYI @fbasso, @divdavem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants