Skip to content

Commit 8170569

Browse files
committed
fix(widget-plugin-filtering): wrap popup in FloatingPortal
1 parent dc46b2a commit 8170569

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

packages/shared/widget-plugin-filtering/src/controls/filter-selector/FilterSelector.tsx

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { FloatingPortal } from "@floating-ui/react";
12
import classNames from "classnames";
23
import { createElement, useMemo } from "react";
34
import { useSelect } from "./useSelect";
@@ -38,26 +39,29 @@ export function FilterSelector(props: FilterSelectorProps): React.ReactElement {
3839
>
3940
 
4041
</button>
41-
<ul
42-
className={classNames("filter-selectors", { hidden: !open, visible: open })}
43-
{...listboxProps}
44-
style={floatingStyles}
45-
>
46-
{open &&
47-
options.map((item, index) => (
48-
<li
49-
className={classNames("filter-listitem", {
50-
"filter-selected": selectedItem?.value === item.value,
51-
"filter-highlighted": highlightedIndex === index
52-
})}
53-
key={item.value}
54-
{...getItemProps({ item, index })}
55-
>
56-
<div className={classNames("filter-icon", item.value)} aria-hidden />
57-
<div className="filter-label">{item.caption}</div>
58-
</li>
59-
))}
60-
</ul>
42+
{open && (
43+
<FloatingPortal>
44+
<ul
45+
className={classNames("filter-selectors", { hidden: !open, visible: open })}
46+
{...listboxProps}
47+
style={floatingStyles}
48+
>
49+
{options.map((item, index) => (
50+
<li
51+
className={classNames("filter-listitem", {
52+
"filter-selected": selectedItem?.value === item.value,
53+
"filter-highlighted": highlightedIndex === index
54+
})}
55+
key={item.value}
56+
{...getItemProps({ item, index })}
57+
>
58+
<div className={classNames("filter-icon", item.value)} aria-hidden />
59+
<div className="filter-label">{item.caption}</div>
60+
</li>
61+
))}
62+
</ul>
63+
</FloatingPortal>
64+
)}
6165
</div>
6266
</div>
6367
);

0 commit comments

Comments
 (0)