Skip to content

Commit d00b812

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 737d221 commit d00b812

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/components/input/SelectNext.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,6 @@ function SelectMain<T>({
286286
const listboxId = useId();
287287
const buttonRef = useSyncedRef(elementRef);
288288
const defaultButtonId = useId();
289-
const extraProps = useMemo(
290-
() => (listboxAsPopover ? { popover: '' } : {}),
291-
[listboxAsPopover],
292-
);
293289

294290
useListboxPositioning(
295291
buttonRef,
@@ -376,7 +372,6 @@ function SelectMain<T>({
376372
</button>
377373
<SelectContext.Provider value={{ selectValue, value }}>
378374
<ul
379-
{...extraProps}
380375
className={classnames(
381376
'absolute z-5 max-h-80 overflow-y-auto',
382377
'rounded border bg-white shadow hover:shadow-md focus-within:shadow-md',
@@ -397,6 +392,10 @@ function SelectMain<T>({
397392
aria-orientation="vertical"
398393
data-testid="select-listbox"
399394
data-listbox-open={listboxOpen}
395+
// nb. Use `undefined` rather than `false` because Preact doesn't
396+
// handle boolean values correctly for this attribute (it will set
397+
// `popover="false"` instead of removing the attribute).
398+
popover={listboxAsPopover ? 'auto' : undefined}
400399
>
401400
{children}
402401
</ul>

0 commit comments

Comments
 (0)