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({
3434 * since this will repeat trigger `onOpenChange` event.
3535 */
3636 const preventBlurRef = React . useRef < boolean > ( false ) ;
37- const cancelRef = React . useRef ( {
38- onCancel,
39- } ) ;
40- cancelRef . current . onCancel = onCancel ;
4137
4238 const inputProps : React . DOMAttributes < HTMLInputElement > = {
4339 onMouseDown : ( ) => {
@@ -102,7 +98,7 @@ export default function usePickerInput({
10298 if ( blurToCancel ) {
10399 setTimeout ( ( ) => {
104100 if ( isClickOutside ( document . activeElement ) ) {
105- cancelRef . current . onCancel ( ) ;
101+ onCancel ( ) ;
106102 }
107103 } , 0 ) ;
108104 } else {
Original file line number Diff line number Diff line change @@ -9,14 +9,16 @@ export default function useTextValueMapping<ValueType>({
99 onTextChange : ( text : string ) => void ;
1010} ) : [ string , ( text : string ) => void , ( ) => void ] {
1111 const [ text , setInnerText ] = React . useState ( '' ) ;
12+ const valueTextsRef = React . useRef < string [ ] > ( [ ] ) ;
13+ valueTextsRef . current = valueTexts ;
1214
1315 function triggerTextChange ( value : string ) {
1416 setInnerText ( value ) ;
1517 onTextChange ( value ) ;
1618 }
1719
1820 function resetText ( ) {
19- setInnerText ( valueTexts [ 0 ] ) ;
21+ setInnerText ( valueTextsRef . current [ 0 ] ) ;
2022 }
2123
2224 React . useEffect ( ( ) => {
You can’t perform that action at this time.
0 commit comments