File tree Expand file tree Collapse file tree 1 file changed +18
-18
lines changed
packages/kit-headless/src/components/popover Expand file tree Collapse file tree 1 file changed +18
-18
lines changed Original file line number Diff line number Diff line change @@ -4,29 +4,29 @@ import { PopoverImpl } from './popover-impl';
4
4
import { PopoverImplProps } from './popover-impl' ;
5
5
import { FloatingProps } from './floating' ;
6
6
7
- type PopoverProps = PopoverImplProps & ( { floating ?: true } & FloatingProps ) ;
7
+ // TODO: improve the type so that it only includes FloatingProps when floating is true.
8
+ type PopoverProps = PopoverImplProps & { floating ?: boolean } & FloatingProps ;
8
9
9
10
/* This component determines whether the popover needs floating behavior, a common example where it doesn't, would be a toast. */
10
- export const Popover = component$ < PopoverProps > (
11
- ( { floating, anchorRef, ref, ...props } ) => {
12
- if ( floating ) {
13
- if ( ! anchorRef ) {
14
- throw new Error (
15
- 'Qwik UI Popover: anchorRef is required on the popover when floating is true' ,
16
- ) ;
17
- }
18
-
19
- return (
20
- < FloatingPopover ref = { ref } anchorRef = { anchorRef } { ...props } >
21
- < Slot />
22
- </ FloatingPopover >
11
+ export const Popover = component$ < PopoverProps > ( ( props ) => {
12
+ if ( props . floating ) {
13
+ const { ref, anchorRef, ...rest } = props ;
14
+ if ( ! anchorRef ) {
15
+ throw new Error (
16
+ 'Qwik UI Popover: anchorRef is required on the popover when floating is true' ,
23
17
) ;
24
18
}
25
19
26
20
return (
27
- < PopoverImpl { ...props } >
21
+ < FloatingPopover ref = { ref } anchorRef = { anchorRef } { ...rest } >
28
22
< Slot />
29
- </ PopoverImpl >
23
+ </ FloatingPopover >
30
24
) ;
31
- } ,
32
- ) ;
25
+ }
26
+
27
+ return (
28
+ < PopoverImpl { ...props } >
29
+ < Slot />
30
+ </ PopoverImpl >
31
+ ) ;
32
+ } ) ;
You can’t perform that action at this time.
0 commit comments