Skip to content

Commit

Permalink
Fixes old browser compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
m1aw committed Sep 6, 2021
1 parent e339ed2 commit 18af4b3
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ function Select(props: SelectProps) {
*/
const handleClickOutside = (e: MouseEvent) => {
// use composedPath so it can also check when inside a web component
if (!e.composedPath().includes(selectContainerRef.current)) {
// if composedPath is not available fallback to e.target
const clickIsOutside = e.composedPath ?
!e.composedPath().includes(selectContainerRef.current) :
!selectContainerRef.current.contains(e.target);
if (clickIsOutside) {
setShowList(false);
}
};
Expand Down

0 comments on commit 18af4b3

Please sign in to comment.