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
  • Loading branch information
nongzhou.yh committed Feb 24, 2021
1 parent c0963ac commit afa37bc
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

0 comments on commit afa37bc

Please sign in to comment.