File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -165,20 +165,22 @@ function ModalDialog(props) {
165
165
166
166
function Example() {
167
167
let state = useOverlayTriggerState ({});
168
+ let openButtonRef = React .useRef ();
169
+ let closeButtonRef = React .useRef ();
168
170
169
171
// useButton ensures that focus management is handled correctly,
170
172
// across all browsers. Focus is restored to the button once the
171
173
// dialog closes.
172
174
let {buttonProps : openButtonProps} = useButton ({
173
175
onPress : () => state .open ()
174
- });
176
+ }, openButtonRef );
175
177
176
178
let {buttonProps : closeButtonProps} = useButton ({
177
179
onPress : () => state .close ()
178
- });
180
+ }, closeButtonRef );
179
181
180
182
return <>
181
- <button { ... openButtonProps } >Open Dialog</button >
183
+ <button { ... openButtonProps } ref = { openButtonRef } >Open Dialog</button >
182
184
{ state .isOpen &&
183
185
<OverlayContainer >
184
186
<ModalDialog
@@ -195,6 +197,7 @@ function Example() {
195
197
</label >
196
198
<button
197
199
{ ... closeButtonProps }
200
+ ref = { closeButtonRef }
198
201
style = { {marginTop: 10 }} >
199
202
Submit
200
203
</button >
Original file line number Diff line number Diff line change @@ -195,7 +195,7 @@ function Example() {
195
195
// popover closes.
196
196
let {buttonProps} = useButton ({
197
197
onPress : () => state .open ()
198
- });
198
+ }, triggerRef );
199
199
200
200
return <>
201
201
<button
You can’t perform that action at this time.
0 commit comments