Skip to content

Commit 9cc245e

Browse files
committed
feat: Add an option to select text-input date on input blur (resolves #1182)
1 parent 463a5d4 commit 9cc245e

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/VueDatePicker/components/DatePickerInput/DatepickerInput.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,10 @@
272272
if (!props.isMenuOpen || (inline.value.enabled && inline.value.input)) {
273273
emit('blur');
274274
}
275-
if (rootProps.autoApply && textInput.value.enabled && parsedDate.value && !props.isMenuOpen) {
275+
if (
276+
(rootProps.autoApply && textInput.value.enabled && parsedDate.value && !props.isMenuOpen) ||
277+
textInput.value.applyOnBlur
278+
) {
276279
emit('set-input-date', parsedDate.value);
277280
emit('select-date');
278281
parsedDate.value = null;

src/VueDatePicker/constants/defaults.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export const defaultTextInputOptions = {
4545
escClose: true,
4646
format: undefined,
4747
maskFormat: undefined,
48+
applyOnBlur: false,
4849
};
4950

5051
export const defaultHighlightOptions = {

src/VueDatePicker/types/configs.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export interface TextInputConfig {
122122
escClose: boolean;
123123
format: string | string[] | ((value: string) => Date | null);
124124
maskFormat: string;
125+
applyOnBlur: boolean;
125126
}
126127

127128
export interface RangeConfig {

0 commit comments

Comments
 (0)