File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -40,14 +40,22 @@ export type PopoverPropsType = {
40
40
41
41
/**
42
42
* Determine if hover should affect popover visibility.
43
+ * @default true
43
44
*/
44
45
useHover ?: boolean ;
45
46
46
47
/**
47
48
* Determine if click should affect popover visibility.
49
+ * @default true
48
50
*/
49
51
useClick ?: boolean ;
50
52
53
+ /**
54
+ * Determine if focus should affect popover visibility.
55
+ * @default true
56
+ */
57
+ useFocus ?: boolean ;
58
+
51
59
/**
52
60
* Only controlled component. Handle Popover open state change.
53
61
*/
@@ -63,6 +71,7 @@ const Popover = ({
63
71
id,
64
72
useHover,
65
73
useClick,
74
+ useFocus,
66
75
defaultOpen = false ,
67
76
open,
68
77
role,
@@ -76,6 +85,7 @@ const Popover = ({
76
85
onOpenChange,
77
86
useHover,
78
87
useClick,
88
+ useFocus,
79
89
role,
80
90
} ) ;
81
91
Original file line number Diff line number Diff line change 6
6
useClick as useFloatingClick ,
7
7
useHover as useFloatingHover ,
8
8
useRole ,
9
- useFocus ,
9
+ useFocus as useFloatingFocus ,
10
10
offset ,
11
11
flip ,
12
12
arrow ,
@@ -29,6 +29,7 @@ interface UsePopoverPropTypes {
29
29
open ?: boolean ;
30
30
useHover ?: boolean ;
31
31
useClick ?: boolean ;
32
+ useFocus ?: boolean ;
32
33
role ?: PopoverRole ;
33
34
onOpenChange ?: ( arg0 : boolean ) => void ;
34
35
}
@@ -40,6 +41,7 @@ const usePopover = ({
40
41
open,
41
42
useHover = true ,
42
43
useClick = true ,
44
+ useFocus = true ,
43
45
role = 'dialog' ,
44
46
onOpenChange,
45
47
} : UsePopoverPropTypes ) => {
@@ -130,7 +132,9 @@ const usePopover = ({
130
132
blockPointerEvents : true ,
131
133
} ) ,
132
134
} ) ;
133
- const focus = useFocus ( data . context ) ;
135
+ const focus = useFloatingFocus ( data . context , {
136
+ enabled : useFocus ,
137
+ } ) ;
134
138
const click = useFloatingClick ( data . context , {
135
139
enabled : useClick ,
136
140
} ) ;
You can’t perform that action at this time.
0 commit comments