Extended `sap.ui.core.TooltipBase`: delegate event handlers tightly coupled with the tooltip owner
Recently I discovered that:
- Framework hooks, such as
onlocalizationChangedandonThemeChanged, 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:
- Open the above sample.
- Right-click on the preview and inspect the element to open the browser console.
- Enter
- Either
sap.ui.getCore().applyTheme("sap_belize");in order to triggeronThemeChanged - Or
sap.ui.getCore().getConfiguration().setLanguage(<lang-code>);in order to triggeronlocalizationChanged.
- Either
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":
- In
this[sHandlerName]()whereasthis=== the custom tooltip control - In
oDelegate[sHandlerName].call(/*...*/)whereasthat=== 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.
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 I enhanced the initial issue description as it applies not only to onlocalizationChanged and onThemeChanged but also to other delegate event handlers.
Fixed with 49af667398f5861c9b3cc2ec0c361aa5c309e39d
We faced some issues for controls extending the sap.ui.core.TooltipBase. Therefore created an internal incident 2280194709.