ui5-webcomponents icon indicating copy to clipboard operation
ui5-webcomponents copied to clipboard

Tooltip is not showing when show-tooltip is set to true on ui5-icon

Open gurkirpalgill opened this issue 6 years ago • 6 comments

Tooltip is not showing when show-tooltip is set to true on ui5-icon

Expected behavior When using ui5-icon as: <ui5-icon class="ui5-button-icon" name="action-settings" show-tooltip="true" ></ui5-icon> Tooltip should be visible when show-tooltip is set to true.

Actual behavior Tooltip does not show.

Screenshots

Priority: (optional) (Medium)

gurkirpalgill avatar Nov 06 '20 02:11 gurkirpalgill

Hello @gurkirpalgill

Only 4 icons (message-error/warning/information/success) out of 600 has built in tooltips. To have a tooltip for your icon, pass the desired text via the accessible-name attribute.

We will update the showTooltip docs to make it clear.

Best, ilhan

ilhan007 avatar Nov 06 '20 05:11 ilhan007

icon is shown through the ui5-button, so I do not have direct access to the icon itself. if i set accessible-name on button, it does not work.

<ui5-button design="Transparent" icon="decline" ref={declineRef} accessible-name="Close" slot="endButton" onClick={() => removeUserEvent(i)}></ui5-button>

I am able to set the accessible-name programmatically but it its not ideal.There should be a declarative option to set the accessible-name through the button itself if it's setting the icon. Right now I have to do something like this:

useEffect(() => {
    if (!declineRef.current) {
      return;
    }
    const setTooltip = async () => {
      await RenderScheduler.whenFinished();
      const shadow = declineRef.current.shadowRoot;
      if (shadow.querySelector("ui5-icon")) {
        shadow.querySelector("ui5-icon").setAttribute("accessible-name", "Close");
      }
    }
    setTooltip();
  });

Providing an attribute e.g. icon-accessible-name that sets the icon tooltip is desirable:

<ui5-button design="Transparent" icon="decline" ref={declineRef} icon-accessible-name="Close" slot="endButton" onClick={() => removeUserEvent(i)}></ui5-button>

gurkirpalgill avatar Nov 06 '20 23:11 gurkirpalgill

@ilhan007 when do you think the fix will be available ?

gurkirpalgill avatar Nov 10 '20 16:11 gurkirpalgill

The icon-accessible-name="Close" is not an API that we would like to have, I would suggest trying: and perhaps use some styles, if something is not perfectly centred:

<ui5-button>
     <ui5-icon accessible-name="Close" name="decline">
</ui5-button

ilhan007 avatar Nov 10 '20 16:11 ilhan007

Hi @gurkirpalgill

As much as I can understand from your issue, you need a tooltip for icon only button. If this is the case, I think that the following PR might be exactly what you need.

fifoosid avatar Nov 24 '20 09:11 fifoosid

Closing due to inactivity. You can reopen the issue anytime if you have additional input.

ilhan007 avatar Jan 13 '21 05:01 ilhan007