We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 68ceb33 commit 53071acCopy full SHA for 53071ac
src/hooks/usePickerInput.ts
@@ -34,6 +34,10 @@ export default function usePickerInput({
34
* since this will repeat trigger `onOpenChange` event.
35
*/
36
const preventBlurRef = React.useRef<boolean>(false);
37
+ const cancelRef = React.useRef({
38
+ onCancel,
39
+ });
40
+ cancelRef.current.onCancel = onCancel;
41
42
const inputProps: React.DOMAttributes<HTMLInputElement> = {
43
onMouseDown: () => {
@@ -98,7 +102,7 @@ export default function usePickerInput({
98
102
if (blurToCancel) {
99
103
setTimeout(() => {
100
104
if (isClickOutside(document.activeElement)) {
101
- onCancel();
105
+ cancelRef.current.onCancel();
106
}
107
}, 0);
108
} else {
0 commit comments