Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): datepicker addon button should not be tabindex, popover opens with f4 key #12496

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libs/core/date-picker/date-picker.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
[attr.aria-describedby]="_formValueStateMessageId"
[ngModel]="_inputFieldDate"
(keyup.enter)="handleInputChange($any($event.target).value, false)"
(keydown.f4)="toggleCalendar()"
(ngModelChange)="handleInputChange($event, true)"
(click)="mobile && openCalendar()"
(blur)="_onBlur($event)"
Expand Down
8 changes: 8 additions & 0 deletions libs/core/date-picker/date-picker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,14 @@ describe('DatePickerComponent', () => {
expect(component.selectedMultipleDateRangesChange.emit).not.toHaveBeenCalled();
expect(component.isModelValid()).toBe(false);
});

it('should toggle the calendar with the f4 key', () => {
jest.spyOn(component, 'toggleCalendar');
component._inputElement.nativeElement.dispatchEvent(new KeyboardEvent('keydown', {
key: 'f4'
}));
expect(component.toggleCalendar).toHaveBeenCalled();
});
});

describe('DatePickerComponent Accessibility', () => {
Expand Down
5 changes: 2 additions & 3 deletions libs/core/date-picker/date-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,10 @@ export class DatePickerComponent<D>
}

/**
* Whether AddOn Button should be focusable
* @default true
* @deprecated Popover is toggled with f4 key
*/
@Input()
buttonFocusable = true;
buttonFocusable = false;

/**
* Special days mark, it can be used by passing array of object with
Expand Down
1 change: 1 addition & 0 deletions libs/core/datetime-picker/datetime-picker.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
[placeholder]="placeholder"
[disabled]="disabled"
[ngModel]="_inputFieldDate | translateDayPeriod"
(keydown.f4)="togglePopover()"
(keyup.enter)="handleInputChange($any($event.target).value, false)"
(ngModelChange)="handleInputChange($event, true)"
(blur)="handleOnTouched($event)"
Expand Down
8 changes: 8 additions & 0 deletions libs/core/datetime-picker/datetime-picker.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ describe('DatetimePickerComponent', () => {
expect(component._inputFieldDate).toEqual('1/25/2022');
expect(component._isInvalidDateInput).toEqual(false);
});

it('should toggle the popover with the f4 key', () => {
jest.spyOn(component, 'togglePopover');
component._inputElement.nativeElement.dispatchEvent(new KeyboardEvent('keydown', {
key: 'f4'
}));
expect(component.togglePopover).toHaveBeenCalled();
});
});

const DATE_TIME_PICKER_IDENTIFIER = 'core-date-time-picker-unit-test';
Expand Down
5 changes: 2 additions & 3 deletions libs/core/datetime-picker/datetime-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,10 @@ export class DatetimePickerComponent<D>
}

/**
* Whether AddOn Button should be focusable
* @default true
* @deprecated Popover is toggled with f4 key
*/
@Input()
buttonFocusable = true;
buttonFocusable = false;

/**
* Special days mark, it can be used by passing array of object with
Expand Down