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';
44import { PopoverImplProps } from './popover-impl' ;
55import { FloatingProps } from './floating' ;
66
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 ;
89
910/* 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' ,
2317 ) ;
2418 }
2519
2620 return (
27- < PopoverImpl { ...props } >
21+ < FloatingPopover ref = { ref } anchorRef = { anchorRef } { ...rest } >
2822 < Slot />
29- </ PopoverImpl >
23+ </ FloatingPopover >
3024 ) ;
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