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
71 changes: 71 additions & 0 deletions packages/main/cypress/specs/TimePicker.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,77 @@ describe("Validation inside a form", () => {
});
});

describe("Icon Tooltip Tests", () => {
it("TimePicker icon tooltip changes when toggling picker", () => {
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");
});
});

describe("CSS Parts", () => {
it("TimePicker exposes input CSS part through DateTimeInput", () => {
cy.mount(<TimePicker />);
Expand Down
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 @@ -487,6 +489,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 @@ -40,6 +40,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 @@ -549,6 +549,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