SAP / openui5

OpenUI5 lets you build enterprise-ready web applications, responsive to all devices, running on almost any browser of your choice.
http://openui5.org
Apache License 2.0
2.96k stars 1.24k forks source link

fix(sap.ui.unified): provide fallback icon constructor for menu item in case custom image is provided #3929

Closed dfenerski closed 8 months ago

dfenerski commented 10 months ago

This change would provide a fallback constructor to the createControlByURI call, which will then be used in case the provided src is not in the icon pool.

Solves #3928

flovogt commented 9 months ago

Thanks for this fix. I have created an internal incident DINC0034912. The responsible team will get in touch with you and follow-up here on github.

Jansen214 commented 9 months ago

Thanks to @dfenerski for this fix! Until the new version is available we are using the following workaround that might be helpful to others who end up here. Just add this as a Custom Control and use it instead of the default sap.m.MenuItem.

sap.ui.define([
    'sap/m/MenuItem',
    'sap/ui/core/IconPool',
    'sap/m/Image'
], function(MenuItem, IconPool, Image) {
    "use strict";

    var CustomMenuItem = MenuItem.extend("sap.m.CustomMenuItem");

    CustomMenuItem.prototype._setVisualControl = function(vControl) {
        vControl._getIcon = function(oItem) {
            return IconPool.createControlByURI({
                src: oItem.getIcon(),
                useIconTooltip: false
            }, Image);
        }
        this._setInternalRef(vControl, "_sVisualControl");
    };

    return CustomMenuItem;
});
didip1000 commented 8 months ago

Hello @dfenerski,

Thank you for your fix, it is now merged and will be available in the next UI5 release (version 1.122).

Best, Diana