Skip to content

Commit

Permalink
Merge pull request #1272 from Adyen/fix/web_component_dropdown
Browse files Browse the repository at this point in the history
Fixes dropdown on Web Components
  • Loading branch information
m1aw authored Sep 6, 2021
2 parents 09f1fed + 18af4b3 commit 8216698
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ function Select(props: SelectProps) {
* @param e - MouseEvent
*/
const handleClickOutside = (e: MouseEvent) => {
if (!selectContainerRef.current.contains(e.target)) {
// use composedPath so it can also check when inside a web component
// 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 8216698

Please sign in to comment.