Skip to content

Commit 145c7a4

Browse files
committed
Update popover declaration for compatibility with Preact typings
Preact's latest typings allow setting popover to a boolean value, but this still renders `popover="true"` and "true" is an invalid value. Instead set the value to "auto" which is the default value [1]. [1] https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/popover
1 parent 297d525 commit 145c7a4

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/components/input/SelectNext.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
useContext,
66
useId,
77
useLayoutEffect,
8-
useMemo,
98
useRef,
109
useState,
1110
} from 'preact/hooks';
@@ -286,10 +285,6 @@ function SelectMain<T>({
286285
const listboxId = useId();
287286
const buttonRef = useSyncedRef(elementRef);
288287
const defaultButtonId = useId();
289-
const extraProps = useMemo(
290-
() => (listboxAsPopover ? { popover: '' } : {}),
291-
[listboxAsPopover],
292-
);
293288

294289
useListboxPositioning(
295290
buttonRef,
@@ -376,7 +371,6 @@ function SelectMain<T>({
376371
</button>
377372
<SelectContext.Provider value={{ selectValue, value }}>
378373
<ul
379-
{...extraProps}
380374
className={classnames(
381375
'absolute z-5 max-h-80 overflow-y-auto',
382376
'rounded border bg-white shadow hover:shadow-md focus-within:shadow-md',
@@ -397,6 +391,10 @@ function SelectMain<T>({
397391
aria-orientation="vertical"
398392
data-testid="select-listbox"
399393
data-listbox-open={listboxOpen}
394+
// nb. Use `undefined` rather than `false` because Preact doesn't
395+
// handle boolean values correctly for this attribute (it will set
396+
// `popover="false"` instead of removing the attribute).
397+
popover={listboxAsPopover ? 'auto' : undefined}
400398
>
401399
{children}
402400
</ul>

0 commit comments

Comments
 (0)