@@ -121,6 +121,9 @@ export const useInput = (props: ParamsTypeInputHook): ReturnTypeInputHook => {
121
121
return ;
122
122
}
123
123
if ( eventKeyPressRef . current && props . mask && inputRef ?. current && value ) {
124
+ const popoverElements = document . querySelectorAll (
125
+ '[data-calendar], [data-input-dropdown-list], [data-input-search-list]'
126
+ ) ;
124
127
const { start, end } = eventKeyPressRef . current . cursor ;
125
128
// if multiple digits are selected, recovery the selected area
126
129
const area = Math . abs ( start - end ) ;
@@ -138,7 +141,10 @@ export const useInput = (props: ParamsTypeInputHook): ReturnTypeInputHook => {
138
141
eventKeyPressRef . current . cursor ,
139
142
positionRef . current
140
143
) ;
141
- inputRef . current . focus ( ) ;
144
+
145
+ if ( popoverElements . length !== 0 ) {
146
+ inputRef . current . focus ( ) ;
147
+ }
142
148
inputRef . current . setSelectionRange ( start + diffStart + position , end - diffEnd + position ) ;
143
149
}
144
150
} , [ value ] ) ;
@@ -356,7 +362,12 @@ export const useInput = (props: ParamsTypeInputHook): ReturnTypeInputHook => {
356
362
const handlePasteInternal : React . ClipboardEventHandler < HTMLInputElement > = event => {
357
363
const clipboardData = event . clipboardData ;
358
364
const pastedData = clipboardData ?. getData ( 'Text' ) ;
359
- if ( props . ignoreKeys ?. some ( key => pastedData . includes ( key ) ) || props . disabledCopyAndPaste ) {
365
+ const newRegex = typeof props . regex === 'string' ? new RegExp ( props . regex ) : props . regex ;
366
+ if (
367
+ props . ignoreKeys ?. some ( key => pastedData . includes ( key ) ) ||
368
+ props . disabledCopyAndPaste ||
369
+ ( newRegex && ! newRegex ?. test ( pastedData ) )
370
+ ) {
360
371
event . preventDefault ( ) ;
361
372
return ;
362
373
}
0 commit comments