Skip to content

Commit

Permalink
AAE-21799 replace opening datepicker on focus with opening on enter (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
wojd0 committed Apr 8, 2024
1 parent 951b8db commit 966a6b7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
[disabled]="field.readOnly"
(change)="onValueChanged($event)"
(dateChange)="onDateChanged($event)"
(keydown.enter)="datetimePicker.open()"
[placeholder]="field.placeholder"
[matTooltip]="field.tooltip"
(blur)="markAsTouched()"
Expand All @@ -25,9 +26,9 @@
<error-widget [error]="field.validationSummary"></error-widget>
<error-widget *ngIf="isInvalidFieldRequired() && isTouched()" required="{{ 'FORM.FIELD.REQUIRED' | translate }}"></error-widget>
<mat-datetimepicker #datetimePicker
data-automation-id="adf-date-time-widget-picker"
type="datetime"
[touchUi]="true"
[openOnFocus]="true"
[timeInterval]="5"
[disabled]="field.readOnly">
</mat-datetimepicker>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,5 +439,23 @@ describe('DateTimeWidgetComponent', () => {
const adfLeftLabel = element.querySelector('.adf-left-label');
expect(adfLeftLabel).toBeNull();
});

it('should open date-time picker when enter key is pressed', async () => {
widget.field = new FormFieldModel(new FormModel({ taskId: 'fake-task' }), {
id: 'datetime-id',
name: 'datetime-name',
value: '',
type: FormFieldTypes.DATETIME,
readOnly: false,
required: true
});

const input = await loader.getHarness(MatInputHarness);
await input.focus();
await (await input.host()).sendKeys('Enter');

const picker = element.querySelector('[data-automation-id="adf-date-time-widget-picker"]');
expect(picker).toBeTruthy();
});
});
});

0 comments on commit 966a6b7

Please sign in to comment.