diff --git a/packages/main/src/Popup.hbs b/packages/main/src/Popup.hbs index 9f8d21d79c77..5b4cc63873e0 100644 --- a/packages/main/src/Popup.hbs +++ b/packages/main/src/Popup.hbs @@ -8,6 +8,7 @@ dir="{{effectiveDir}}" @keydown={{_onkeydown}} @focusout={{_onfocusout}} + @mouseup={{_onmouseup}} > diff --git a/packages/main/src/Popup.js b/packages/main/src/Popup.js index 689265dddefc..6ed872980e0f 100644 --- a/packages/main/src/Popup.js +++ b/packages/main/src/Popup.js @@ -278,10 +278,17 @@ class Popup extends UI5Element { } _onfocusout(e) { - // relatedTarget is the element, which will get focus. If no such element exists, focus the root + // relatedTarget is the element, which will get focus. If no such element exists, focus the root. if (!e.relatedTarget) { this._root.tabIndex = -1; + this._shouldFocusRoot = true; + } + } + + _onmouseup(e) { + if (document.activeElement !== this && !this.contains(document.activeElement) && this._shouldFocusRoot) { this._root.focus(); + this._shouldFocusRoot = false; } }