diff --git a/lib/core/src/lib/form/components/widgets/date-time/date-time.widget.html b/lib/core/src/lib/form/components/widgets/date-time/date-time.widget.html index 85541b22ea..4e509f6869 100644 --- a/lib/core/src/lib/form/components/widgets/date-time/date-time.widget.html +++ b/lib/core/src/lib/form/components/widgets/date-time/date-time.widget.html @@ -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()" @@ -25,9 +26,9 @@ diff --git a/lib/core/src/lib/form/components/widgets/date-time/date-time.widget.spec.ts b/lib/core/src/lib/form/components/widgets/date-time/date-time.widget.spec.ts index d2b26da973..0838c79b4e 100644 --- a/lib/core/src/lib/form/components/widgets/date-time/date-time.widget.spec.ts +++ b/lib/core/src/lib/form/components/widgets/date-time/date-time.widget.spec.ts @@ -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(); + }); }); });