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-dynamic-page): action containers respect content width #7898

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 3 additions & 6 deletions packages/fiori/src/DynamicPageTitle.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,18 @@
{{/if}}
</div>

<div class="{{classes.wrapper}}"
@ui5-_min-content-width-change={{onMinContentWidthChange}}>
<div class="{{classes.wrapper}}">
<div class="{{classes.heading}}">
<slot name="{{headingSlotName}}"></slot>
</div>

{{#if hasContent}}
<div class="{{classes.content}}"
style="{{styles.content}}">
<div class="{{classes.content}}">
<slot></slot>
</div>
{{/if}}

<div class="{{classes.actions}}"
style="{{styles.actions}}">
<div class="{{classes.actions}}">
<slot name="actions"></slot>
{{#unless mobileNavigationActions}}
<div class="{{classes.actionsSeparator}}"></div>
Expand Down
23 changes: 0 additions & 23 deletions packages/fiori/src/DynamicPageTitle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type I18nBundle from "@ui5/webcomponents-base/dist/i18nBundle.js";
import ResizeHandler from "@ui5/webcomponents-base/dist/delegate/ResizeHandler.js";
import type { ResizeObserverCallback } from "@ui5/webcomponents-base/dist/delegate/ResizeHandler.js";
import type Toolbar from "@ui5/webcomponents/dist/Toolbar.js";
import type { ToolbarMinWidthChangeEventDetail } from "@ui5/webcomponents/dist/Toolbar.js";

// Template
import DynamicPageTitleTemplate from "./generated/templates/DynamicPageTitleTemplate.lit.js";
Expand Down Expand Up @@ -76,8 +75,6 @@ class DynamicPageTitle extends UI5Element {
mobileNavigationActions!: boolean;

_handleResize: ResizeObserverCallback;
minContentWidth?: number;
minActionsWidth?: number;

constructor() {
super();
Expand Down Expand Up @@ -139,17 +136,6 @@ class DynamicPageTitle extends UI5Element {
};
}

get styles() {
return {
content: {
"min-width": `${this.minContentWidth || 0}px`,
},
actions: {
"min-width": `${this.minActionsWidth || 0}px`,
},
};
}

onEnterDOM() {
ResizeHandler.register(this, this._handleResize);
}
Expand All @@ -176,15 +162,6 @@ class DynamicPageTitle extends UI5Element {
handleResize() {
this.mobileNavigationActions = this.offsetWidth < 1280;
}

onMinContentWidthChange(event: CustomEvent<ToolbarMinWidthChangeEventDetail>) {
const slotName = (<HTMLElement>event.target)?.assignedSlot?.name;
if (!slotName || slotName === "content") {
this.minContentWidth = event.detail.minWidth;
} else if (slotName === "actions") {
this.minActionsWidth = event.detail.minWidth;
}
}
}

DynamicPageTitle.define();
Expand Down
4 changes: 2 additions & 2 deletions packages/fiori/src/themes/DynamicPageTitle.css
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@

.ui5-dynamic-page-title--content {
flex-shrink: 1.6;
min-width: 3rem;
min-width: fit-content;
flex-grow: 1;
}

.ui5-dynamic-page-title--actions {
flex-shrink: 1.6;
min-width: 3rem;
min-width: fit-content;
flex-grow: 1;
display: flex;
}
Expand Down
8 changes: 2 additions & 6 deletions packages/main/src/Toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -429,12 +429,8 @@ class Toolbar extends UI5Element {
minWidth += this.overflowButtonSize;
}

if (minWidth !== this.minContentWidth) {
const spaceAroundContent = this.offsetWidth - this.getDomRef()!.offsetWidth;
this.fireEvent<ToolbarMinWidthChangeEventDetail>("_min-content-width-change", {
minWidth: minWidth + spaceAroundContent,
});
}
const spaceAroundContent = this.offsetWidth - this.getDomRef()!.offsetWidth;
this.style.minWidth = `${minWidth + spaceAroundContent}px`;

this.itemsWidth = totalWidth;
this.minContentWidth = minWidth;
Expand Down