Skip to content

Commit

Permalink
feat(ui5-select): introduced tooltip property
Browse files Browse the repository at this point in the history
New "tooltip" property is introduced to the Select component.

When the property is set to a string, it is shown as tooltip when we
hover over the component.

Implements: SAP#10855
  • Loading branch information
plamenivanov91 committed Feb 24, 2025
1 parent 6f02955 commit cd5606d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/main/cypress/specs/Select.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ describe("Select - Accessibility", () => {
.find("li.ui5-li-root")
.should("have.attr", "title", EXPECTED_TOOLTIP);
});

it("setting tooltip on the host is reflected on the select's shadow dom root", () => {
cy.mount(<Select tooltip="Go home">
<Option value="1">Option 1</Option>
<OptionCustom value="2">Option 2</OptionCustom>
</Select>);

cy.get("[ui5-select]")
.shadow()
.find(".ui5-select-root")
.as("select");

cy.get("@select")
.should("have.attr", "title", "Go home");
});
});

describe("Select - Popover", () => {
Expand Down
9 changes: 9 additions & 0 deletions packages/main/src/Select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,15 @@ class Select extends UI5Element implements IFormInputElement {
@property()
accessibleNameRef?: string;

/**
* Defines the tooltip of the select.
* @default undefined
* @public
* @since 2.8.0
*/
@property()
tooltip?: string;

/**
* @private
*/
Expand Down
1 change: 1 addition & 0 deletions packages/main/src/SelectTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default function SelectTemplate(this: Select) {
}}
id={`${this._id}-select`}
onClick={this._onclick}
title={this.tooltip}
>
{this.selectedOptionIcon &&
<Icon
Expand Down

0 comments on commit cd5606d

Please sign in to comment.