Skip to content

Commit ba834cf

Browse files
fix(popover): fix combobox flicker
1 parent fd57e7e commit ba834cf

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ export const ComboboxTrigger = component$((props: ComboboxTriggerProps) => {
1818
return (
1919
<PopoverTrigger
2020
{...props}
21+
disableClickInitPopover={true}
2122
ref={context.triggerRef}
22-
onMouseDown$={[
23+
onClick$={[
2324
$(() => {
2425
context.isListboxOpenSig.value = !context.isListboxOpenSig.value;
2526
}),
26-
props.onMouseDown$,
27+
props.onClick$,
2728
]}
2829
tabIndex={-1}
2930
aria-haspopup="listbox"

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { isBrowser } from '@builder.io/qwik/build';
44

55
type PopoverTriggerProps = {
66
popovertarget: string;
7+
disableClickInitPopover: boolean;
78
// TODO anchor for floatingui
89
// TODO toggle? on/off?
910
} & QwikIntrinsicElements['button'];
@@ -87,7 +88,7 @@ export function usePopover(popovertarget: string) {
8788
}
8889

8990
export const PopoverTrigger = component$<PopoverTriggerProps>(
90-
({ popovertarget, ...rest }: PopoverTriggerProps) => {
91+
({ popovertarget, disableClickInitPopover = false, ...rest }: PopoverTriggerProps) => {
9192
const { initPopover$ } = usePopover(popovertarget);
9293

9394
return (
@@ -97,9 +98,11 @@ export const PopoverTrigger = component$<PopoverTriggerProps>(
9798
popovertarget={popovertarget}
9899
onClick$={[
99100
rest.onClick$,
100-
$(() => {
101-
initPopover$();
102-
}),
101+
!disableClickInitPopover
102+
? $(() => {
103+
initPopover$();
104+
})
105+
: undefined,
103106
]}
104107
>
105108
<Slot />

0 commit comments

Comments
 (0)