Skip to content

Commit

Permalink
feat!: Add option to set openMenu in text-input to toggle (reso…
Browse files Browse the repository at this point in the history
…lves #905)
  • Loading branch information
Jasenkoo committed Jul 7, 2024
1 parent 58ff212 commit bee7728
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
12 changes: 4 additions & 8 deletions src/VueDatePicker/components/DatepickerInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,9 @@
const handleOpen = (ev: KeyboardEvent | MouseEvent) => {
ev.preventDefault();
checkStopPropagation(ev, defaultedConfig.value, true);
if (
defaultedTextInput.value.enabled &&
defaultedTextInput.value.openMenu &&
!defaultedInline.value.input &&
!props.isMenuOpen
) {
emit('open');
if (defaultedTextInput.value.enabled && defaultedTextInput.value.openMenu && !defaultedInline.value.input) {
if (defaultedTextInput.value.openMenu === 'open' && !props.isMenuOpen) return emit('open');
if (defaultedTextInput.value.openMenu === 'toggle') return emit('toggle');
} else if (!defaultedTextInput.value.enabled) {
emit('toggle');
}
Expand All @@ -304,7 +300,7 @@
const handleKeyPress = (ev: KeyboardEvent, fromInput?: boolean): void => {
if (ev.key === 'Tab') {
handleTab(ev, false);
handleTab(ev, fromInput);
}
if (ev.key === 'Enter') {
handleEnter(ev);
Expand Down
2 changes: 1 addition & 1 deletion src/VueDatePicker/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export interface ICalendarDate {
export interface TextInputOptions {
enterSubmit: boolean;
tabSubmit: boolean;
openMenu: boolean;
openMenu: string | boolean;
rangeSeparator: string;
selectOnFocus: boolean;
format?: string | string[] | ((value: string) => Date | null);
Expand Down
2 changes: 1 addition & 1 deletion src/VueDatePicker/utils/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export const getDefaultTextInputOptions = (textInput: TextInputProp): TextInputO
const defaultOptions = {
enterSubmit: true,
tabSubmit: true,
openMenu: true,
openMenu: 'open',
selectOnFocus: false,
rangeSeparator: ' - ',
};
Expand Down

0 comments on commit bee7728

Please sign in to comment.