Skip to content

Commit 6598cdc

Browse files
fix(ui5-date-picker): add correct tooltip when picker is opened (#12669)
Adding tooltip to Icon button in the input. Using "Open Picker" when closed and "Close Picker" when opened. fixes: #12616
1 parent cacdba0 commit 6598cdc

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

packages/main/cypress/specs/DatePicker.cy.tsx

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,77 @@ describe("Date Picker Tests", () => {
16681668
.ui5DatePickerGetInnerInput()
16691669
.should("have.value", "0202-12-01");
16701670
});
1671+
1672+
it("DatePicker icon tooltip changes when toggling picker", () => {
1673+
cy.mount(<DatePicker />);
1674+
1675+
cy.get("[ui5-date-picker]")
1676+
.as("datePicker");
1677+
1678+
cy.get("@datePicker")
1679+
.should("not.have.attr", "open");
1680+
1681+
cy.get("@datePicker")
1682+
.shadow()
1683+
.find("ui5-icon")
1684+
.as("icon")
1685+
.should("have.attr", "accessible-name", "Open Picker");
1686+
1687+
cy.get("@datePicker")
1688+
.ui5DatePickerValueHelpIconPress();
1689+
1690+
cy.get("@datePicker")
1691+
.should("have.attr", "open");
1692+
1693+
cy.get("@icon")
1694+
.should("have.attr", "accessible-name", "Close Picker");
1695+
1696+
cy.get("@datePicker")
1697+
.ui5DatePickerValueHelpIconPress();
1698+
1699+
cy.get("@datePicker")
1700+
.should("not.have.attr", "open");
1701+
1702+
cy.get("@icon")
1703+
.should("have.attr", "accessible-name", "Open Picker");
1704+
});
1705+
1706+
it("DatePicker icon tooltip changes when using keyboard shortcuts", () => {
1707+
cy.mount(<DatePicker />);
1708+
1709+
cy.get("[ui5-date-picker]")
1710+
.as("datePicker")
1711+
.ui5DatePickerGetInnerInput()
1712+
.as("input")
1713+
.realClick()
1714+
.should("be.focused");
1715+
1716+
cy.get("@datePicker")
1717+
.shadow()
1718+
.find("ui5-icon")
1719+
.as("icon")
1720+
.should("have.attr", "accessible-name", "Open Picker");
1721+
1722+
cy.get("@input")
1723+
.realPress("F4");
1724+
1725+
cy.get("@datePicker")
1726+
.should("have.attr", "open");
1727+
1728+
cy.get("@icon")
1729+
.should("have.attr", "accessible-name", "Close Picker");
1730+
1731+
cy.get("@datePicker")
1732+
.shadow()
1733+
.find("ui5-calendar")
1734+
.realPress("Escape");
1735+
1736+
cy.get("@datePicker")
1737+
.should("not.have.attr", "open");
1738+
1739+
cy.get("@icon")
1740+
.should("have.attr", "accessible-name", "Open Picker");
1741+
});
16711742
});
16721743

16731744

packages/main/src/DatePicker.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import "@ui5/webcomponents-icons/dist/appointment-2.js";
4444

4545
import {
4646
DATEPICKER_OPEN_ICON_TITLE,
47+
DATEPICKER_OPEN_ICON_TITLE_OPENED,
4748
DATEPICKER_DATE_DESCRIPTION,
4849
DATETIME_COMPONENTS_PLACEHOLDER_PREFIX,
4950
INPUT_SUGGESTIONS_TITLE,
@@ -921,6 +922,10 @@ class DatePicker extends DateComponentBase implements IFormInputElement {
921922
}
922923

923924
get openIconTitle() {
925+
if (this.open) {
926+
return DatePicker.i18nBundle.getText(DATEPICKER_OPEN_ICON_TITLE_OPENED);
927+
}
928+
924929
return DatePicker.i18nBundle.getText(DATEPICKER_OPEN_ICON_TITLE);
925930
}
926931

packages/main/src/i18n/messagebundle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ COLORPICKER_ALPHA=Alpha
184184
#XACT: DatePicker 'Open Picker' icon title
185185
DATEPICKER_OPEN_ICON_TITLE=Open Picker
186186

187+
#XACT: DatePicker 'Open Picker' icon title when the picker is opened
188+
DATEPICKER_OPEN_ICON_TITLE_OPENED=Close Picker
189+
187190
#XACT: Aria information for the Date Picker
188191
DATEPICKER_DATE_DESCRIPTION=Date Input
189192

0 commit comments

Comments
 (0)