diff --git a/packages/base/src/features/OpenUI5Support.ts b/packages/base/src/features/OpenUI5Support.ts index b634d78017ce..967422ebec94 100644 --- a/packages/base/src/features/OpenUI5Support.ts +++ b/packages/base/src/features/OpenUI5Support.ts @@ -3,11 +3,8 @@ import { setTheme } from "../config/Theme.js"; import { getCurrentZIndex } from "../util/PopupUtils.js"; import { CLDRData } from "../asset-registries/LocaleData.js"; import type { LegacyDateCalendarCustomizing } from "../features/LegacyDateFormats.js"; - -type OpenUI5Popup = { - setInitialZIndex: (zIndex: number) => void, - getNextZIndex: () => number, -}; +import patchPopup from "./patchPopup.js"; +import type { OpenUI5Popup } from "./patchPopup.js"; type OpenUI5Core = { attachInit: (callback: () => void) => void, @@ -103,6 +100,7 @@ class OpenUI5Support { } window.sap.ui.require(deps, (Popup: OpenUI5Popup) => { Popup.setInitialZIndex(getCurrentZIndex()); + patchPopup(Popup); resolve(); }); }; diff --git a/packages/base/src/features/patchPopup.ts b/packages/base/src/features/patchPopup.ts new file mode 100644 index 000000000000..cc0181a3bc76 --- /dev/null +++ b/packages/base/src/features/patchPopup.ts @@ -0,0 +1,25 @@ +type OpenUI5Popup = { + setInitialZIndex: (zIndex: number) => void, + getNextZIndex: () => number, + prototype: { + onFocusEvent: (e: FocusEvent) => void, + } +}; + +const patchFocusEvent = (Popup: OpenUI5Popup) => { + const origFocusEvent = Popup.prototype.onFocusEvent; + Popup.prototype.onFocusEvent = function onFocusEvent(e: FocusEvent) { + const isTypeFocus = e.type === "focus" || e.type === "activate"; + const target = e.target as HTMLElement; + if (!isTypeFocus || !target.closest("[ui5-popover],[ui5-responsive-popover],[ui5-dialog]")) { + origFocusEvent.call(this, e); + } + }; +}; + +const patchPopup = (Popup: OpenUI5Popup) => { + patchFocusEvent(Popup);// Popup.prototype.onFocusEvent +}; + +export default patchPopup; +export type { OpenUI5Popup }; diff --git a/packages/main/test/pages/DialogAndOpenUI5Dialog.html b/packages/main/test/pages/DialogAndOpenUI5Dialog.html new file mode 100644 index 000000000000..688175bc098a --- /dev/null +++ b/packages/main/test/pages/DialogAndOpenUI5Dialog.html @@ -0,0 +1,96 @@ + + + + + + + Dialog + + + + + + + +
+ Open WebC Dialog +
+ + Open UI5 dialog + + + Some button + +
+ + Some button + + + \ No newline at end of file