Skip to content
Open
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
100 changes: 100 additions & 0 deletions packages/main/cypress/specs/TimePicker.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -543,4 +543,104 @@ describe("Validation inside a form", () => {
cy.get("#timePicker:invalid")
.should("not.exist", "Timepicker with correct formatted value should not have :invalid CSS class");
});
});

describe("Icon Tooltip Tests", () => {
it("TimePicker icon shows correct tooltip when closed", () => {
cy.mount(<TimePicker />);

cy.get<TimePicker>("[ui5-time-picker]")
.as("timePicker")
.should("not.have.attr", "open");

cy.get<TimePicker>("@timePicker")
.shadow()
.find("ui5-icon")
.should("have.attr", "accessible-name", "Open Picker");
});

it("TimePicker icon shows correct tooltip when opened", () => {
cy.mount(<TimePicker />);

cy.get<TimePicker>("[ui5-time-picker]")
.as("timePicker")
.ui5TimePickerValueHelpIconPress();

cy.get<TimePicker>("@timePicker")
.should("have.attr", "open");

cy.get<TimePicker>("@timePicker")
.shadow()
.find("ui5-icon")
.should("have.attr", "accessible-name", "Close Picker");
});

it("TimePicker icon tooltip changes when toggling picker", () => {
Copy link
Contributor

@unazko unazko Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The third test covers the first two. We can either use the first two tests or the third one. One of them is redundant.

cy.mount(<TimePicker />);

cy.get<TimePicker>("[ui5-time-picker]")
.as("timePicker");

cy.get<TimePicker>("@timePicker")
.should("not.have.attr", "open");

cy.get<TimePicker>("@timePicker")
.shadow()
.find("ui5-icon")
.as("icon")
.should("have.attr", "accessible-name", "Open Picker");

cy.get<TimePicker>("@timePicker")
.ui5TimePickerValueHelpIconPress();

cy.get<TimePicker>("@timePicker")
.should("have.attr", "open");

cy.get("@icon")
.should("have.attr", "accessible-name", "Close Picker");

cy.get<TimePicker>("@timePicker")
.ui5TimePickerValueHelpIconPress();

cy.get<TimePicker>("@timePicker")
.should("not.have.attr", "open");

cy.get("@icon")
.should("have.attr", "accessible-name", "Open Picker");
});

it("TimePicker icon tooltip changes when using keyboard shortcuts", () => {
cy.mount(<TimePicker />);

cy.get<TimePicker>("[ui5-time-picker]")
.as("timePicker")
.ui5TimePickerGetInnerInput()
.as("input")
.realClick()
.should("be.focused");

cy.get<TimePicker>("@timePicker")
.shadow()
.find("ui5-icon")
.as("icon")
.should("have.attr", "accessible-name", "Open Picker");

cy.get("@input")
.realPress("F4");

cy.get<TimePicker>("@timePicker")
.should("have.attr", "open");

cy.get("@icon")
.should("have.attr", "accessible-name", "Close Picker");

cy.get("@input")
.realPress(["Alt", "ArrowUp"]);

cy.get<TimePicker>("@timePicker")
.should("not.have.attr", "open");

cy.get("@icon")
.should("have.attr", "accessible-name", "Open Picker");
});
});
10 changes: 10 additions & 0 deletions packages/main/src/TimePicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ import {
VALUE_STATE_WARNING,
TIMEPICKER_VALUE_MISSING,
TIMEPICKER_PATTERN_MISSMATCH,
TIMEPICKER_OPEN_ICON_TITLE_OPENED,
TIMEPICKER_OPEN_ICON_TITLE,
} from "./generated/i18n/i18n-defaults.js";

// Styles
Expand Down Expand Up @@ -486,6 +488,14 @@ class TimePicker extends UI5Element implements IFormInputElement {
this.tempValue = e.detail.value; // every time the user changes the time selection -> update tempValue
}

get openIconTitle() {
if (this.open) {
return TimePicker.i18nBundle.getText(TIMEPICKER_OPEN_ICON_TITLE_OPENED);
}

return TimePicker.i18nBundle.getText(TIMEPICKER_OPEN_ICON_TITLE);
}

_togglePicker() {
this.open = !this.open;
if (this._isMobileDevice) {
Expand Down
1 change: 1 addition & 0 deletions packages/main/src/TimePickerTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default function TimePickerTemplate(this: TimePicker) {
name={timeEntryRequest}
tabindex={-1}
showTooltip={true}
accessibleName={this.openIconTitle}
mode={this._iconMode}
onClick={this._togglePicker}
class={{
Expand Down
6 changes: 6 additions & 0 deletions packages/main/src/i18n/messagebundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,12 @@ TIMEPICKER_INPUTS_ENTER_MINUTES=Please enter minutes
#XACT: Time Picker Inputs tooltip/aria-label for Seconds input
TIMEPICKER_INPUTS_ENTER_SECONDS=Please enter seconds

#XACT: Time Picker 'Open Picker' icon title
TIMEPICKER_OPEN_ICON_TITLE=Open Picker

#XACT: Time Picker 'Open Picker' icon title when the picker is opened
TIMEPICKER_OPEN_ICON_TITLE_OPENED=Close Picker

TIMEPICKER_VALUE_MISSING=Fill in the time value in the format: {0}.

TIMEPICKER_PATTERN_MISSMATCH=This format is not supported. Fill in the time value in the format: {0}.
Expand Down
Loading