AAE-21799 replace opening datepicker on focus with opening on enter (#9526)

This commit is contained in:
Wojciech Duda 2024-04-08 16:53:10 +02:00 committed by GitHub
parent 951b8dbe5a
commit 966a6b7cc0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 1 deletions

View File

@ -13,6 +13,7 @@
[disabled]="field.readOnly" [disabled]="field.readOnly"
(change)="onValueChanged($event)" (change)="onValueChanged($event)"
(dateChange)="onDateChanged($event)" (dateChange)="onDateChanged($event)"
(keydown.enter)="datetimePicker.open()"
[placeholder]="field.placeholder" [placeholder]="field.placeholder"
[matTooltip]="field.tooltip" [matTooltip]="field.tooltip"
(blur)="markAsTouched()" (blur)="markAsTouched()"
@ -25,9 +26,9 @@
<error-widget [error]="field.validationSummary"></error-widget> <error-widget [error]="field.validationSummary"></error-widget>
<error-widget *ngIf="isInvalidFieldRequired() && isTouched()" required="{{ 'FORM.FIELD.REQUIRED' | translate }}"></error-widget> <error-widget *ngIf="isInvalidFieldRequired() && isTouched()" required="{{ 'FORM.FIELD.REQUIRED' | translate }}"></error-widget>
<mat-datetimepicker #datetimePicker <mat-datetimepicker #datetimePicker
data-automation-id="adf-date-time-widget-picker"
type="datetime" type="datetime"
[touchUi]="true" [touchUi]="true"
[openOnFocus]="true"
[timeInterval]="5" [timeInterval]="5"
[disabled]="field.readOnly"> [disabled]="field.readOnly">
</mat-datetimepicker> </mat-datetimepicker>

View File

@ -439,5 +439,23 @@ describe('DateTimeWidgetComponent', () => {
const adfLeftLabel = element.querySelector('.adf-left-label'); const adfLeftLabel = element.querySelector('.adf-left-label');
expect(adfLeftLabel).toBeNull(); 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();
});
}); });
}); });