Skip to content

Commit

Permalink
fix: bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Yiiu committed Jan 9, 2024
1 parent d723758 commit 01205a1
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/components/tag_select/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,19 @@ const TagSelect = ({ options = [], value = [], onChange }) => {
}

React.useEffect(() => {
if (open) {
const shadowDiv = document.querySelector('#shadowroot')
const shadowRoot = shadowDiv.shadowRoot

const shadowDiv = document.querySelector('#shadowroot')
if (!shadowDiv) {
return
}
const shadowRoot = shadowDiv.shadowRoot
if (open && shadowRoot) {
if (!shadowRoot) {
return
}
shadowRoot.addEventListener('click', handleDocumentClick)
}
return () => {
document.body.removeEventListener('click', handleDocumentClick)
return () => {
shadowRoot.removeEventListener('click', handleDocumentClick)
}
}
}, [open])
return (
Expand Down

0 comments on commit 01205a1

Please sign in to comment.