SAP / ui5-webcomponents

UI5 Web Components - the enterprise-flavored sugar on top of native APIs! Build SAP Fiori user interfaces with the technology of your choice.
https://sap.github.io/ui5-webcomponents/
Apache License 2.0
1.56k stars 267 forks source link

ui-dialog throws error when used with OpenUI5Support #4445

Closed lateefsofi closed 2 years ago

lateefsofi commented 2 years ago

Bug Description

ui5-dialog show method is throwing error when used with OpenUI5Support

Expected Behavior

ui5-dialog should open with out any error.

Steps to Reproduce

  1. Go to 'https://codesandbox.io/s/ui5-webcomponents-forked-qebrk?file=/src/index.js'
  2. Click "Open Dialog" button

Isolated Example

https://codesandbox.io/s/ui5-webcomponents-forked-qebrk?file=/src/index.js

Context

Log Output / Stack Trace / Screenshots

PopupUtils.js:75 Uncaught (in promise) TypeError: OpenUI5Support.getNextZIndex is not a function
    at getNextZIndex (PopupUtils.js:75)
    at HTMLElement._open (Popup.js:400)
    at HTMLElement.show (Dialog.js:226)
    at setDialogOpen (index.js:24)
    at index.js:32
    at commitHookEffectList (react-dom.development.js:22030)
    at commitPassiveHookEffects (react-dom.development.js:22064)
    at HTMLUnknownElement.callCallback (react-dom.development.js:336)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:385)
    at invokeGuardedCallback (react-dom.development.js:440)

Priority

Stakeholder Info (if applicable)

ilhan007 commented 2 years ago

Hello @lateefsofi as explained offline

you need to import the feature itself: @ui5/webcomponents-base/dist/features/OpenUI5Support.js and not the registerFeature to register your own OpenUI5Support as I see in the provided sample.

It will work If you import: import "@ui5/webcomponents-base/dist/features/OpenUI5Support.js"; instead of: import "./ui5Config.js";

ndeshev commented 2 years ago

Hello,

I've modified the code snippet to just import the OpenUI5Support.js as it registers itself and in general the methods should not be overridden/mocked the way they are in the code provided above, as Ilhan pointed.

I added OpenUI5 to the page to test the OpenUI5Support feature.
Modified snippet - https://codesandbox.io/s/klf8b

The issue is reproducible, error is thrown from line #85 in OpenUI5Support.js which is called by PopupUtils.js (line #105)

  const Popup = window.sap.ui.require("sap/ui/core/Popup");
  return Popup.getNextZIndex();

window.sap.ui.require("sap/ui/core/Popup")returns undefined as if the module is not loaded, although the UI5 core library seems to be loaded.

Could you please check it.

vladitasev commented 2 years ago

Hello,

Sorry for the delay in response. I just checked the CodeSandbox and it worked fine after I deleted the override of the feature definition.

Please see for example: https://codesandbox.io/s/ui5-webcomponents-forked-z2utcf?file=/src/ui5Config.js:0-66

Regards, Vladi