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

AAE-21799 Dont open date-time picker on focus in date-time form widget #9526

Merged
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
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();
});
});
});
Loading