Skip to content
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
31 changes: 31 additions & 0 deletions packages/main/cypress/specs/DatePicker.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,38 @@ describe("Date Picker Tests", () => {
.should("have.attr", "placeholder", "test placeholder");
});

it("clear icon", () => {
cy.mount(<DatePicker showClearIcon={true} value="Jan 1, 2020" formatPattern="MMM d, y"></DatePicker>);

cy.get("[ui5-date-picker]")
.as("datePicker");

cy.get<DatePicker>("@datePicker")
.shadow()
.find("ui5-datetime-input")
.shadow()
.find(".ui5-input-clear-icon")
.should("exist");

cy.get<DatePicker>("@datePicker")
.shadow()
.find("ui5-datetime-input")
.shadow()
.find(".ui5-input-clear-icon-wrapper")
.click();

cy.get<DatePicker>("@datePicker")
.shadow()
.find("ui5-datetime-input")
.shadow()
.find(".ui5-input-clear-icon")
.should("not.exist");

cy.realPress("Tab");

cy.get<DatePicker>("@datePicker")
.should("have.value", "");
});

it("Selected date from daypicker is the same as datepicker date", () => {
cy.mount(<DatePicker value="Jan 29, 2019" formatPattern="MMM d, y"></DatePicker>);
Expand Down
9 changes: 9 additions & 0 deletions packages/main/src/DatePicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,15 @@ class DatePicker extends DateComponentBase implements IFormInputElement {
@property()
accessibleDescriptionRef?: string;

/**
* Defines whether the clear icon of the input will be shown.
* @default false
* @public
* @since 2.20.0
*/
@property({ type: Boolean })
showClearIcon = false;

@property({ type: Object })
_respPopoverConfig?: object;

Expand Down
1 change: 1 addition & 0 deletions packages/main/src/DatePickerInputTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default function DatePickerInputTemplate(this: DatePicker) {
onInput={this._onInputInput}
onui5-_request-submit={this._onInputRequestSubmit}
onKeyDown={this._onkeydown}
showClearIcon={this.showClearIcon}
>

{!this.open && this.valueStateMessage.length > 0 &&
Expand Down
4 changes: 2 additions & 2 deletions packages/main/src/themes/DatePicker.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
}

:host .ui5-date-picker-input {
width: 100%;
color: inherit;
background-color: inherit;
border-radius: inherit;
Expand All @@ -63,4 +62,5 @@

.ui5-date-picker-popover::part(header) {
padding: 0;
}
}

2 changes: 2 additions & 0 deletions packages/main/src/themes/DateTimePicker.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
}

:host .ui5-date-picker-input {
width: 100%;
min-width: inherit;
color: inherit;
background-color: inherit;

}
Loading
Loading