File tree 4 files changed +14
-2
lines changed
4 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -199,6 +199,7 @@ export interface VueDatePickerProps {
199
199
rangeSeparator ?: string ;
200
200
selectOnFocus ?: boolean ;
201
201
format ?: string | string [ ] | ( ( value : string ) => Date | null ) ;
202
+ escClose ?: boolean ;
202
203
} ;
203
204
monthNameFormat ?: 'long' | 'short' ;
204
205
startDate ?: string | Date ;
Original file line number Diff line number Diff line change 58
58
@click =" emit('toggle')"
59
59
/>
60
60
</div >
61
- <span v-if =" $slots['clear-icon'] && (alwaysClearable || inputValue && clearable && !disabled && !readonly)" class =" dp--clear-btn"
61
+ <span
62
+ v-if =" $slots['clear-icon'] && (alwaysClearable || (inputValue && clearable && !disabled && !readonly))"
63
+ class =" dp--clear-btn"
62
64
><slot name =" clear-icon" :clear =" onClear"
63
65
/></span >
64
66
<button
65
- v-if =" !$slots['clear-icon'] && (alwaysClearable || clearable && inputValue && !disabled && !readonly)"
67
+ v-if =" !$slots['clear-icon'] && (alwaysClearable || ( clearable && inputValue && !disabled && !readonly) )"
66
68
:aria-label =" defaultedAriaLabels?.clearInput"
67
69
class =" dp--clear-btn"
68
70
type =" button"
290
292
emit (' clear' );
291
293
};
292
294
295
+ const handleEsc = () => {
296
+ emit (' close' );
297
+ };
298
+
293
299
const handleKeyPress = (ev : KeyboardEvent ): void => {
294
300
if (ev .key === ' Tab' ) {
295
301
handleTab (ev );
296
302
}
297
303
if (ev .key === ' Enter' ) {
298
304
handleEnter (ev );
299
305
}
306
+ if (ev .key === ' Escape' && defaultedTextInput .value .escClose ) {
307
+ handleEsc ();
308
+ }
300
309
if (! defaultedTextInput .value .enabled ) {
301
310
if (ev .code === ' Tab' ) return ;
302
311
ev .preventDefault ();
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ export interface TextInputOptions {
47
47
openMenu : string | boolean ;
48
48
rangeSeparator : string ;
49
49
selectOnFocus : boolean ;
50
+ escClose : boolean ;
50
51
format ?: string | string [ ] | ( ( value : string ) => Date | null ) ;
51
52
}
52
53
Original file line number Diff line number Diff line change @@ -123,6 +123,7 @@ export const getDefaultTextInputOptions = (textInput: TextInputProp): TextInputO
123
123
openMenu : 'open' ,
124
124
selectOnFocus : false ,
125
125
rangeSeparator : ' - ' ,
126
+ escClose : true ,
126
127
} ;
127
128
128
129
if ( typeof textInput === 'object' ) {
You can’t perform that action at this time.
0 commit comments