openui5 icon indicating copy to clipboard operation
openui5 copied to clipboard

Extended `sap.ui.core.TooltipBase`: delegate event handlers tightly coupled with the tooltip owner

Open boghyon opened this issue 5 years ago • 5 comments

Recently I discovered that:

  • Framework hooks, such as onlocalizationChanged and onThemeChanged, are triggered twice.
  • Other pseudo or browser events, such as onfocusin, are handled in the custom tooltip control for the tooltip owner control as well.

URL (minimal example if possible)

https://embed.plnkr.co/33zFqa?show=control%2FTooltip.js,preview

Steps to reproduce the problem:

  1. Open the above sample.
  2. Right-click on the preview and inspect the element to open the browser console.
  3. Enter
    • Either sap.ui.getCore().applyTheme("sap_belize"); in order to trigger onThemeChanged
    • Or sap.ui.getCore().getConfiguration().setLanguage(<lang-code>); in order to trigger onlocalizationChanged.

Any other information? (attach screenshot if possible)

When a tooltip is being set, the parent control calls _refreshTooltipBaseDelegate:

https://github.com/SAP/openui5/blob/310f072a062e5a2908df23a07946edccfb1682d8/src/sap.ui.core/src/sap/ui/core/Element.js#L926-L932

In _refreshTooltipBaseDelegate, the tooltip instance itself is added as a degelate (this.addDelegate(oTooltip)):

https://github.com/SAP/openui5/blob/310f072a062e5a2908df23a07946edccfb1682d8/src/sap.ui.core/src/sap/ui/core/Element.js#L900-L911

This causes triggering the hooks twice in _handleEvent when, for example, the theme has changed:

https://github.com/SAP/openui5/blob/310f072a062e5a2908df23a07946edccfb1682d8/src/sap.ui.core/src/sap/ui/core/Element.js#L306-L342

Given sHandlerName === "onThemeChanged":

  1. In this[sHandlerName]() whereas this === the custom tooltip control
  2. In oDelegate[sHandlerName].call(/*...*/) whereas that === the tooltip owner control

Why is the tooltip object added as a delegate in the first place? That was not clear from the source code. It would be nice if the hooks could be triggered only once, and other on... event handlers working independently from the tooltip owner control.

boghyon avatar Feb 20 '21 11:02 boghyon

Hello boghyon,

thank you for submitting this issue. I could reproduce the issue and forwarded it to the responsible development team. They will consult you directly for further processing. Please refer to the internal incident 2180121255 for further questions.

Regards Sebastian

HerzogIgzorn avatar Feb 22 '21 08:02 HerzogIgzorn

@HerzogIgzorn I enhanced the initial issue description as it applies not only to onlocalizationChanged and onThemeChanged but also to other delegate event handlers.

boghyon avatar Jul 03 '21 21:07 boghyon

Fixed with 49af667398f5861c9b3cc2ec0c361aa5c309e39d

flovogt avatar Dec 15 '22 11:12 flovogt

We faced some issues for controls extending the sap.ui.core.TooltipBase. Therefore created an internal incident 2280194709.

flovogt avatar Dec 15 '22 13:12 flovogt