diff --git a/packages/chonky/src/components/browser-shell/BrowserShell.tsx b/packages/chonky/src/components/browser-shell/BrowserShell.tsx index 0b4ef018..f35094d1 100644 --- a/packages/chonky/src/components/browser-shell/BrowserShell.tsx +++ b/packages/chonky/src/components/browser-shell/BrowserShell.tsx @@ -115,6 +115,10 @@ const sortItems = (items: readonly BrowserItem[], sort: BrowserSortState): reado return sorted; }; +// Reused across every item render so we don't allocate an Intl.NumberFormat per +// tile (large grids would otherwise pay that cost on each render). +const itemCountFormatter = new Intl.NumberFormat(); + const formatSize = (sizeBytes?: number): string => { if (typeof sizeBytes !== 'number') return ''; if (sizeBytes < 1024) return `${sizeBytes} B`; @@ -922,9 +926,12 @@ const BrowserShellItem: React.FC = (props) => { )}
- {item.name} + {/* title exposes the full name when the label is truncated. */} + {item.name} - {item.kind === 'folder' ? `${item.childCount ?? 0} items` : formatSize(item.sizeBytes)} + {item.kind === 'folder' + ? `${itemCountFormatter.format(item.childCount ?? 0)} ${item.childCount === 1 ? 'item' : 'items'}` + : formatSize(item.sizeBytes)} {item.source?.label ? ` ยท ${item.source.label}` : ''}