@@ -10,6 +10,7 @@ import {
10
10
useOnWindow ,
11
11
useStore ,
12
12
useVisibleTask$ ,
13
+ QwikIntrinsicElements ,
13
14
} from '@builder.io/qwik' ;
14
15
import { computePosition , flip } from '@floating-ui/dom' ;
15
16
@@ -70,17 +71,22 @@ export const SelectRoot = component$(
70
71
const listBox = track ( ( ) => contextService . listBoxRef . value ) ;
71
72
const expanded = track ( ( ) => isExpanded . value ) ;
72
73
73
- if ( expanded && trigger && listBox ) {
74
- updatePosition ( trigger , listBox ) ;
74
+ if ( ! trigger || ! listBox ) return ;
75
+
76
+ if ( expanded === true ) {
77
+ listBox . style . visibility = 'hidden' ;
78
+
79
+ await updatePosition ( trigger , listBox ) ;
80
+
81
+ listBox . style . visibility = 'visible' ;
82
+
83
+ listBox ?. focus ( ) ;
75
84
}
76
85
86
+
77
87
if ( expanded === false ) {
78
88
trigger ?. focus ( ) ;
79
89
}
80
-
81
- if ( expanded === true ) {
82
- listBox ?. focus ( ) ;
83
- }
84
90
} ) ;
85
91
86
92
useOnWindow (
@@ -113,9 +119,9 @@ export const SelectRoot = component$(
113
119
}
114
120
) ;
115
121
116
- export interface TriggerProps extends StyleProps {
122
+ export type TriggerProps = {
117
123
disabled ?: boolean ;
118
- }
124
+ } & QwikIntrinsicElements [ 'button' ] ;
119
125
120
126
export const SelectTrigger = component$ (
121
127
( { disabled, ...props } : TriggerProps ) => {
@@ -128,7 +134,8 @@ export const SelectTrigger = component$(
128
134
ref = { ref }
129
135
aria-expanded = { contextService . isExpanded . value }
130
136
disabled = { disabled }
131
- onClick$ = { ( ) => {
137
+ onClick$ = { ( e ) => {
138
+ e . stopPropagation ( ) ;
132
139
contextService . isExpanded . value = ! contextService . isExpanded . value ;
133
140
} }
134
141
onKeyDown$ = { ( e ) => {
0 commit comments