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

[select] fix(Suggest2): get root node correctly in Shadow DOM #5462

Merged
merged 2 commits into from
Jul 25, 2022
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
3 changes: 2 additions & 1 deletion packages/select/src/components/suggest/suggest2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ export class Suggest2<T> extends AbstractPureComponent2<Suggest2Props<T>, Sugges
// Note that we defer to the next animation frame in order to get the latest document.activeElement
private handlePopoverInteraction = (nextOpenState: boolean, event?: React.SyntheticEvent<HTMLElement>) =>
this.requestAnimationFrame(() => {
const isInputFocused = this.inputElement === document.activeElement;
const rootNode = (this.inputElement?.getRootNode?.() ?? document) as DocumentOrShadowRoot & Node;
const isInputFocused = this.inputElement === rootNode.activeElement;

if (this.inputElement != null && !isInputFocused) {
// the input is no longer focused, we should close the popover
Expand Down