File tree Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -34,10 +34,6 @@ export default function usePickerInput({
34
34
* since this will repeat trigger `onOpenChange` event.
35
35
*/
36
36
const preventBlurRef = React . useRef < boolean > ( false ) ;
37
- const cancelRef = React . useRef ( {
38
- onCancel,
39
- } ) ;
40
- cancelRef . current . onCancel = onCancel ;
41
37
42
38
const inputProps : React . DOMAttributes < HTMLInputElement > = {
43
39
onMouseDown : ( ) => {
@@ -102,7 +98,7 @@ export default function usePickerInput({
102
98
if ( blurToCancel ) {
103
99
setTimeout ( ( ) => {
104
100
if ( isClickOutside ( document . activeElement ) ) {
105
- cancelRef . current . onCancel ( ) ;
101
+ onCancel ( ) ;
106
102
}
107
103
} , 0 ) ;
108
104
} else {
Original file line number Diff line number Diff line change @@ -9,14 +9,16 @@ export default function useTextValueMapping<ValueType>({
9
9
onTextChange : ( text : string ) => void ;
10
10
} ) : [ string , ( text : string ) => void , ( ) => void ] {
11
11
const [ text , setInnerText ] = React . useState ( '' ) ;
12
+ const valueTextsRef = React . useRef < string [ ] > ( [ ] ) ;
13
+ valueTextsRef . current = valueTexts ;
12
14
13
15
function triggerTextChange ( value : string ) {
14
16
setInnerText ( value ) ;
15
17
onTextChange ( value ) ;
16
18
}
17
19
18
20
function resetText ( ) {
19
- setInnerText ( valueTexts [ 0 ] ) ;
21
+ setInnerText ( valueTextsRef . current [ 0 ] ) ;
20
22
}
21
23
22
24
React . useEffect ( ( ) => {
You can’t perform that action at this time.
0 commit comments