Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui5-tab-container): implement overflow-button slot #2192

Merged
merged 2 commits into from
Sep 14, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/main/src/Popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,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;
}

/**
Expand Down
21 changes: 14 additions & 7 deletions packages/main/src/TabContainer.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,21 @@

<!-- overflow button -->
{{#if showOverflow}}
<ui5-button
<div
@click="{{_onOverflowButtonClick}}"
class="{{classes.overflowButton}}"
icon="{{overflowMenuIcon}}"
design="Transparent"
aria-label="{{overflowMenuTitle}}"
aria-haspopup="true"
></ui5-button>
>
{{#if overflowButton.length}}
<slot name="overflowButton"></slot>
{{else}}
<ui5-button
class="{{classes.overflowButton}}"
icon="{{overflowMenuIcon}}"
design="Transparent"
aria-label="{{overflowMenuTitle}}"
aria-haspopup="true"
></ui5-button>
{{/if}}
</div>
{{/if}}
</div>

Expand Down
20 changes: 19 additions & 1 deletion packages/main/src/TabContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ const metadata = {
individualSlots: true,
listenFor: { include: ["*"] },
},

/**
* Defines the buttons which is shown when there are overflowed items. If nothing is provided to this slot, the default button will be used.
fifoosid marked this conversation as resolved.
Show resolved Hide resolved
*
* @type {HTMLElement[]}
* @public
* @slot
* @since 1.0.0-rc.9
*/
overflowButton: {
type: HTMLElement,
invalidateParent: true,
fifoosid marked this conversation as resolved.
Show resolved Hide resolved
},
},
properties: /** @lends sap.ui.webcomponents.main.TabContainer.prototype */ {
/**
Expand Down Expand Up @@ -427,9 +440,14 @@ class TabContainer extends UI5Element {
}

async _onOverflowButtonClick(event) {
const button = this.overflowButton[0] || this.getDomRef().querySelector(".ui-tc__overflowButton");
this.responsivePopover = await this._respPopover();
this.updateStaticAreaItemContentDensity();
this.responsivePopover.open(this.getDomRef().querySelector(".ui-tc__overflowButton"));
if (this.responsivePopover.opened) {
fifoosid marked this conversation as resolved.
Show resolved Hide resolved
this.responsivePopover.close();
} else {
this.responsivePopover.open(button);
}
}

_onHeaderBackArrowClick() {
Expand Down
24 changes: 23 additions & 1 deletion packages/main/test/pages/TabContainer.html
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,29 @@ <h2>tabs-placement=Bottom</h2>
<ui5-button>Button 3</ui5-button>
</ui5-tab>
</ui5-tabcontainer>
</section>
</section>

<section>
<h2>Tab Container With Custom Menu Button</h2>
<ui5-tabcontainer id="tabContainer1" fixed collapsed show-overflow>
<ui5-tab stable-dom-ref="products-ref" text="Products" additional-text="125">
</ui5-tab>
<ui5-tab-separator></ui5-tab-separator>
<ui5-tab icon="sap-icon://menu2" text="Laptops" semantic-color="Positive" additional-text="25">
</ui5-tab>
<ui5-tab icon="sap-icon://menu" text="Monitors" selected semantic-color="Critical" additional-text="45">
</ui5-tab>
<ui5-tab icon="sap-icon://menu2" text="Keyboards" semantic-color="Negative" additional-text="15">
</ui5-tab>
<ui5-tab icon="sap-icon://menu2" disabled text="Disabled" semantic-color="Negative" additional-text="40">
</ui5-tab>
<ui5-tab icon="sap-icon://menu2" text="Neutral" semantic-color="Neutral" additional-text="40">
</ui5-tab>
<ui5-tab icon="sap-icon://menu2" text="Default" additional-text="40">
</ui5-tab>
<ui5-button slot="overflowButton" aria-label="Menu icon here" icon="menu" design="Transparent"></ui5-button>
</ui5-tabcontainer>
</section>

<script>
document.getElementById("tabContainer1").addEventListener("ui5-tabSelect", function (event) {
Expand Down