Skip to content

Commit 44745e9

Browse files
fix(popover): get popover to work with everything in combobox
1 parent 79c9ece commit 44745e9

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

packages/kit-headless/src/components/combobox/combobox-input.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
getNextEnabledOptionIndex,
1616
getPrevEnabledOptionIndex,
1717
} from './utils';
18-
import { usePopover } from '../popover';
1918

2019
export type ComboboxInputProps = {
2120
disableOnBlur?: boolean;
@@ -27,8 +26,6 @@ export const ComboboxInput = component$(
2726
...props
2827
}: ComboboxInputProps) => {
2928
const context = useContext(ComboboxContextId as ContextId<ComboboxContext<O>>);
30-
const triggerId = `${context.localId}-trigger`;
31-
const { initPopover$ } = usePopover(triggerId);
3229

3330
const inputId = props.id || `${context.localId}-input`;
3431
const listboxId = `${context.localId}-listbox`;
@@ -152,7 +149,7 @@ export const ComboboxInput = component$(
152149
}
153150
aria-controls={listboxId}
154151
value={context.inputValueSig.value}
155-
onInput$={[onInputBehavior$, props.onInput$, initPopover$]}
152+
onInput$={[onInputBehavior$, props.onInput$]}
156153
onBlur$={[
157154
$(() => {
158155
disableOnBlur ? null : (context.isListboxOpenSig.value = false);

packages/kit-headless/src/components/combobox/combobox-popover.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { component$, useContext, Slot, useTask$ } from '@builder.io/qwik';
2-
import { Popover } from '../popover';
2+
import { Popover, usePopover } from '../popover';
33

44
import ComboboxContextId from './combobox-context-id';
55
import { FloatingProps } from '../popover/floating';
@@ -9,6 +9,7 @@ export const ComboboxPopover = component$(
99
(props: Partial<FloatingProps & PopoverImplProps>) => {
1010
const context = useContext(ComboboxContextId);
1111
const popoverId = `${context.localId}-popover`;
12+
const { initPopover$ } = usePopover(popoverId);
1213

1314
/* REMEMBER, whenever an option is selected or onMouseDown$ the listbox is closed, and the popover should sync to that */
1415
useTask$(async ({ track }) => {
@@ -18,6 +19,7 @@ export const ComboboxPopover = component$(
1819
console.log('LISTBOX OPEN: ', context.isListboxOpenSig.value);
1920

2021
if (context.isListboxOpenSig.value) {
22+
await initPopover$();
2123
context.popoverRef.value?.showPopover();
2224
} else {
2325
context.popoverRef.value?.hidePopover();

0 commit comments

Comments
 (0)