Skip to content

Commit

Permalink
fix: document.activeElement cannot get correct dom when the component…
Browse files Browse the repository at this point in the history
… is placed in shadow dom (#221)

Co-authored-by: nongzhou.yh <nongzhou.yh@alibaba-inc.com>
  • Loading branch information
rzyanhao and nongzhou.yh authored Feb 24, 2021
1 parent c0963ac commit ee9180a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/hooks/usePickerInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ export default function usePickerInput({

if (blurToCancel) {
setTimeout(() => {
if (isClickOutside(document.activeElement)) {
let { activeElement } = document;
while (activeElement && activeElement.shadowRoot) {
activeElement = activeElement.shadowRoot.activeElement;
}

if (isClickOutside(activeElement)) {
onCancel();
}
}, 0);
Expand Down

1 comment on commit ee9180a

@vercel
Copy link

@vercel vercel bot commented on ee9180a Feb 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.