Skip to content

Commit 12b483f

Browse files
committed
Fix block list inline mode (#20745)
* Fix block list inline mode #20618 * Fixed potential runtime errors * Code cleanup * Fixed Code Health Review * Revert some changes Commented out unused state properties and related code. * Remove commented-out state property in block workspace view * fix localization * no need for question mark after ids, they should be presented as required --------- Co-authored-by: Niels Lyngsø <[email protected]> Co-authored-by: Niels Lyngsø <[email protected]>
1 parent 7502a38 commit 12b483f

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

src/Umbraco.Web.UI.Client/src/packages/block/block/workspace/views/edit/block-workspace-view-edit-content-no-router.element.ts

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import type { UmbWorkspaceViewElement } from '@umbraco-cms/backoffice/workspace'
1414
*/
1515
@customElement('umb-block-workspace-view-edit-content-no-router')
1616
export class UmbBlockWorkspaceViewEditContentNoRouterElement extends UmbLitElement implements UmbWorkspaceViewElement {
17-
//private _hasRootProperties = false;
17+
// private _hasRootProperties = false;
1818

1919
@state()
2020
private _hasRootGroups = false;
@@ -25,9 +25,6 @@ export class UmbBlockWorkspaceViewEditContentNoRouterElement extends UmbLitEleme
2525
@state()
2626
private _activeTabKey?: string | null | undefined;
2727

28-
//@state()
29-
//private _activeTabName?: string | null | undefined;
30-
3128
#blockWorkspace?: typeof UMB_BLOCK_WORKSPACE_CONTEXT.TYPE;
3229
#tabsStructureHelper = new UmbContentTypeContainerStructureHelper(this);
3330

@@ -67,46 +64,45 @@ export class UmbBlockWorkspaceViewEditContentNoRouterElement extends UmbLitEleme
6764
#checkDefaultTabName() {
6865
if (!this._tabs || !this.#blockWorkspace) return;
6966

70-
// Find the default tab to grab:
67+
// Find the default tab to grab
7168
if (this._activeTabKey === undefined) {
7269
if (this._hasRootGroups) {
73-
//this._activeTabName = null;
7470
this._activeTabKey = null;
7571
} else if (this._tabs.length > 0) {
76-
//this._activeTabName = this._tabs[0].name;
77-
this._activeTabKey = this._tabs[0].key;
72+
const tab = this._tabs[0];
73+
this._activeTabKey = tab.ownerId ?? tab.ids[0];
7874
}
7975
}
8076
}
8177

82-
#setTabName(tabName: string | undefined | null, tabKey: string | null | undefined) {
83-
//this._activeTabName = tabName;
78+
#setTabKey(tabKey: string | null | undefined) {
8479
this._activeTabKey = tabKey;
8580
}
8681

8782
override render() {
8883
if (!this._tabs) return;
84+
8985
return html`
9086
${this._tabs.length > 1 || (this._tabs.length === 1 && this._hasRootGroups)
91-
? html` <uui-tab-group slot="header">
87+
? html`<uui-tab-group slot="header">
9288
${this._hasRootGroups && this._tabs.length > 0
93-
? html`
94-
<uui-tab
95-
label="Content"
96-
.active=${null === this._activeTabKey}
97-
@click=${() => this.#setTabName(null, null)}
98-
>Content</uui-tab
99-
>
100-
`
89+
? html`<uui-tab
90+
label=${this.localize.term('general_generic')}
91+
.active=${this._activeTabKey === null}
92+
@click=${() => this.#setTabKey(null)}
93+
>Content</uui-tab
94+
>`
10195
: nothing}
10296
${repeat(
10397
this._tabs,
10498
(tab) => tab.name,
10599
(tab) => {
100+
const tabKey = tab.ownerId ?? tab.ids[0];
101+
106102
return html`<uui-tab
107-
label=${tab.name ?? 'Unnamed'}
108-
.active=${tab.key === this._activeTabKey}
109-
@click=${() => this.#setTabName(tab.name, tab.key)}
103+
label=${this.localize.string(tab.name ?? '#general_unnamed')}
104+
.active=${this._activeTabKey === tabKey}
105+
@click=${() => this.#setTabKey(tabKey)}
110106
>${tab.name}</uui-tab
111107
>`;
112108
},

0 commit comments

Comments
 (0)