|
| 1 | +import { FloatingPortal } from "@floating-ui/react"; |
1 | 2 | import classNames from "classnames"; |
2 | 3 | import { createElement, useMemo } from "react"; |
3 | 4 | import { useSelect } from "./useSelect"; |
@@ -38,26 +39,29 @@ export function FilterSelector(props: FilterSelectorProps): React.ReactElement { |
38 | 39 | > |
39 | 40 | |
40 | 41 | </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 | + )} |
61 | 65 | </div> |
62 | 66 | </div> |
63 | 67 | ); |
|
0 commit comments