@@ -13,6 +13,7 @@ export default function usePickerInput({
1313 onKeyDown,
1414 blurToCancel,
1515 changeOnBlur,
16+ hasExtraFooter,
1617 onSubmit,
1718 onCancel,
1819 onFocus,
@@ -25,14 +26,16 @@ export default function usePickerInput({
2526 forwardKeyDown : ( e : React . KeyboardEvent < HTMLInputElement > ) => boolean ;
2627 onKeyDown : ( e : React . KeyboardEvent < HTMLInputElement > , preventDefault : ( ) => void ) => void ;
2728 blurToCancel ?: boolean ;
28- changeOnBlur ?: boolean
29+ changeOnBlur ?: boolean ;
30+ hasExtraFooter ?: boolean ;
2931 onSubmit : ( ) => void | boolean ;
3032 onCancel : ( ) => void ;
3133 onFocus ?: React . FocusEventHandler < HTMLInputElement > ;
3234 onBlur ?: React . FocusEventHandler < HTMLInputElement > ;
3335} ) : [ React . DOMAttributes < HTMLInputElement > , { focused : boolean ; typing : boolean } ] {
3436 const [ typing , setTyping ] = useState ( false ) ;
3537 const [ focused , setFocused ] = useState ( false ) ;
38+ const [ outside , setOutside ] = useState ( true ) ;
3639
3740 /**
3841 * We will prevent blur to handle open event when user click outside,
@@ -108,7 +111,7 @@ export default function usePickerInput({
108111 } ,
109112
110113 onBlur : ( e ) => {
111- if ( preventBlurRef . current || ! isClickOutside ( document . activeElement ) ) {
114+ if ( preventBlurRef . current || ! isClickOutside ( document . activeElement ) || ! outside ) {
112115 preventBlurRef . current = false ;
113116 return ;
114117 }
@@ -152,6 +155,11 @@ export default function usePickerInput({
152155 const target = getTargetFromEvent ( e ) ;
153156 const clickedOutside = isClickOutside ( target ) ;
154157
158+ if ( hasExtraFooter ) {
159+ // Save whether the last click is inside the component when `extraFooter` exists.
160+ setOutside ( clickedOutside ) ;
161+ }
162+
155163 if ( open ) {
156164 if ( ! clickedOutside ) {
157165 preventBlurRef . current = true ;
0 commit comments