Skip to content

Commit 059463c

Browse files
committed
feat(metadata-view): Add Subheader for Metadata View v2
1 parent 8a3fcb5 commit 059463c

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

i18n/en-US.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ be.breadcrumb.breadcrumbLabel = Breadcrumb
9292
be.cancel = Cancel
9393
# Label for choose action.
9494
be.choose = Choose
95+
# Aria label for the clear selection button.
96+
be.clearSelection = Clear selection
9597
# Label for close action.
9698
be.close = Close
9799
# Icon title for a Box item of type folder that has collaborators

src/elements/common/messages.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,11 @@ const messages = defineMessages({
387387
description: 'Aria label for the clear button in the search box.',
388388
defaultMessage: 'Clear search',
389389
},
390+
clearSelection: {
391+
id: 'be.clearSelection',
392+
description: 'Aria label for the clear selection button.',
393+
defaultMessage: 'Clear selection',
394+
},
390395
searchPlaceholder: {
391396
id: 'be.searchPlaceholder',
392397
description: 'Shown as a placeholder in the search box.',
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
.be-sub-header-left-v2-selected {
2-
gap: 12px;
1+
.be-SubHeaderLeftV2--selection {
2+
gap: var(--space-3);
33
}

src/elements/common/sub-header/SubHeaderLeftV2.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const SubHeaderLeftV2 = (props: SubHeaderLeftV2Props) => {
2424
const selectedItemText = useMemo(() => {
2525
const selectedCount = selectedItemIds === 'all' ? currentCollection.items.length : selectedItemIds.size;
2626

27-
if (typeof selectedCount !== 'number' || selectedCount === 0) {
27+
if (selectedCount === 0) {
2828
return '';
2929
}
3030

@@ -33,9 +33,7 @@ const SubHeaderLeftV2 = (props: SubHeaderLeftV2Props) => {
3333
const selectedKey =
3434
selectedItemIds === 'all' ? currentCollection.items[0].id : selectedItemIds.values().next().value;
3535
const selectedItem = currentCollection.items.find(item => item.id === selectedKey);
36-
if (typeof selectedItem?.name === 'string') {
37-
return selectedItem.name as string;
38-
}
36+
return selectedItem?.name ?? '';
3937
}
4038
// Case 2: Multiple selected items - show count
4139
if (selectedCount > 1) {
@@ -47,18 +45,18 @@ const SubHeaderLeftV2 = (props: SubHeaderLeftV2Props) => {
4745
// Case 1 and 2: selected item text with X button
4846
if (selectedItemText) {
4947
return (
50-
<PageHeader.Root className="be-sub-header-left-v2-selected" variant="default">
48+
<PageHeader.Root className="be-SubHeaderLeftV2--selection" variant="default">
5149
<PageHeader.Corner>
5250
<IconButton
53-
aria-label="Clear selection"
51+
aria-label={formatMessage(messages.clearSelection)}
5452
icon={XMark}
5553
onClick={onClearSelectedItemIds}
5654
variant="small-utility"
5755
/>
5856
</PageHeader.Corner>
5957

6058
<PageHeader.StartElements>
61-
<Text as="p">{selectedItemText}</Text>
59+
<Text as="span">{selectedItemText}</Text>
6260
</PageHeader.StartElements>
6361
</PageHeader.Root>
6462
);
@@ -67,7 +65,7 @@ const SubHeaderLeftV2 = (props: SubHeaderLeftV2Props) => {
6765
// Case 3: No selected items - show title if provided, otherwise show root name
6866
return (
6967
<Text as="h1" variant="titleXLarge">
70-
{title || rootName}
68+
{title ?? rootName}
7169
</Text>
7270
);
7371
};

src/elements/content-explorer/ContentExplorer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ class ContentExplorer extends Component<ContentExplorerProps, State> {
241241
},
242242
contentUploaderProps: {},
243243
metadataViewProps: {},
244-
title: '',
245244
};
246245

247246
/**

0 commit comments

Comments
 (0)