diff --git a/packages/main/src/Popover.js b/packages/main/src/Popover.js index c1fb83e2a6e3..80ffd695087d 100644 --- a/packages/main/src/Popover.js +++ b/packages/main/src/Popover.js @@ -246,7 +246,7 @@ class Popover extends Popup { isOpenerClicked(event) { const target = event.target; - return target === this._opener || (target.getFocusDomRef && target.getFocusDomRef() === this._opener); + return target === this._opener || (target.getFocusDomRef && target.getFocusDomRef() === this._opener) || event.composedPath().indexOf(this._opener) > -1; } /** diff --git a/packages/main/src/TabContainer.hbs b/packages/main/src/TabContainer.hbs index c1531887559b..55195c74649e 100644 --- a/packages/main/src/TabContainer.hbs +++ b/packages/main/src/TabContainer.hbs @@ -32,15 +32,22 @@ - {{#if showOverflow}} - + > + {{#if overflowButton.length}} + + {{else}} + + {{/if}} + {{/if}} diff --git a/packages/main/src/TabContainer.js b/packages/main/src/TabContainer.js index 8ba34368cb83..633086d47734 100644 --- a/packages/main/src/TabContainer.js +++ b/packages/main/src/TabContainer.js @@ -57,6 +57,18 @@ const metadata = { individualSlots: true, listenFor: { include: ["*"] }, }, + + /** + * Defines the button which will open the overflow menu. If nothing is provided to this slot, the default button will be used. + * + * @type {HTMLElement[]} + * @public + * @slot + * @since 1.0.0-rc.9 + */ + overflowButton: { + type: HTMLElement, + }, }, properties: /** @lends sap.ui.webcomponents.main.TabContainer.prototype */ { /** @@ -427,9 +439,19 @@ class TabContainer extends UI5Element { } async _onOverflowButtonClick(event) { + const button = this.overflowButton[0] || this.getDomRef().querySelector(".ui-tc__overflowButton > ui5-button"); + + if (event.target !== button) { + return; + } + this.responsivePopover = await this._respPopover(); this.updateStaticAreaItemContentDensity(); - this.responsivePopover.open(this.getDomRef().querySelector(".ui-tc__overflowButton")); + if (this.responsivePopover.opened) { + this.responsivePopover.close(); + } else { + this.responsivePopover.open(button); + } } _onHeaderBackArrowClick() { @@ -480,6 +502,10 @@ class TabContainer extends UI5Element { return staticAreaItem.querySelector(`#${this._id}-overflowMenu`); } + get shouldShowOverflow() { + return this.showOverflow && this._scrollable; + } + get classes() { return { root: { @@ -509,10 +535,6 @@ class TabContainer extends UI5Element { "ui5-tc__headerArrowRight": true, "ui5-tc__headerArrow--visible": this._scrollableForward, }, - overflowButton: { - "ui-tc__overflowButton": true, - "ui-tc__overflowButton--visible": this._scrollable, - }, content: { "ui5-tc__content": true, "ui5-tc__content--collapsed": this._contentCollapsed, diff --git a/packages/main/src/themes/TabContainer.css b/packages/main/src/themes/TabContainer.css index 1dc7c8a63968..f1f3d7268dce 100644 --- a/packages/main/src/themes/TabContainer.css +++ b/packages/main/src/themes/TabContainer.css @@ -72,15 +72,10 @@ } .ui-tc__overflowButton { - display: none; margin-left: auto; margin-right: 0.25rem; } -.ui-tc__overflowButton--visible { - display: block; -} - .ui5-tc-root.ui5-tc--textOnly .ui5-tc__content { height: calc(100% - var(--_ui5_tc_header_height_text_only)); /* the header height (text only tabs) */ } diff --git a/packages/main/test/pages/TabContainer.html b/packages/main/test/pages/TabContainer.html index e7e6d83f67c3..55ba643cfa12 100644 --- a/packages/main/test/pages/TabContainer.html +++ b/packages/main/test/pages/TabContainer.html @@ -407,7 +407,29 @@

tabs-placement=Bottom

Button 3 - + + +
+

Tab Container With Custom Menu Button

+ + + + + + + + + + + + + + + + + + +