From 18af4b36a274ef161d59d7ab331993541dacdedc Mon Sep 17 00:00:00 2001 From: antoniof Date: Mon, 6 Sep 2021 14:03:58 +0200 Subject: [PATCH] Fixes old browser compatibility --- .../src/components/internal/FormFields/Select/Select.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/lib/src/components/internal/FormFields/Select/Select.tsx b/packages/lib/src/components/internal/FormFields/Select/Select.tsx index 2acc979d5a..17b2a0bb84 100644 --- a/packages/lib/src/components/internal/FormFields/Select/Select.tsx +++ b/packages/lib/src/components/internal/FormFields/Select/Select.tsx @@ -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); } };