Skip to content

Commit 9322787

Browse files
committed
refactor(core): fold single overflow entry unconditionally, drop foldSingleOverflow flag
1 parent a228c00 commit 9322787

3 files changed

Lines changed: 16 additions & 27 deletions

File tree

packages/core/src/client/webcomponents/components/dock/Dock.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,8 @@ const isRpcTrusted = useIsRpcTrusted(context, (isTrusted) => {
9494
9595
const groupedEntries = computed(() => context.docks.groupedEntries)
9696
97-
// A lone overflowing entry folds back into `visible` (rendered inline) rather
98-
// than earning its own `DockOverflowButton` — see `foldSingleOverflow`.
9997
const splitEntries = computed(() => {
100-
return docksSplitGroupsWithCapacity(groupedEntries.value, layout.value.maxVisibleItems, { foldSingleOverflow: true })
98+
return docksSplitGroupsWithCapacity(groupedEntries.value, layout.value.maxVisibleItems)
10199
})
102100
103101
const selectedEntry = computed(() => {

packages/core/src/client/webcomponents/state/__tests__/dock-sidebar-capacity.test.ts

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,46 +52,39 @@ describe('deriveSidebarCapacity', () => {
5252

5353
describe('docksSplitGroupsWithCapacity (sidebar overflow)', () => {
5454
it('folds members beyond capacity into overflow, preserving order', () => {
55-
const groups: DevToolsDockEntriesGrouped = [['default', [iframe('a'), iframe('b'), iframe('c')]]]
55+
const groups: DevToolsDockEntriesGrouped = [['default', [iframe('a'), iframe('b'), iframe('c'), iframe('d')]]]
5656
const { visible, overflow } = docksSplitGroupsWithCapacity(groups, 2)
5757
expect(visible).toEqual([['default', [iframe('a'), iframe('b')]]])
58-
expect(overflow).toEqual([['default', [iframe('c')]]])
58+
expect(overflow).toEqual([['default', [iframe('c'), iframe('d')]]])
5959
})
6060

6161
it('splits across sub-categories once the first fills capacity', () => {
6262
const groups: DevToolsDockEntriesGrouped = [
6363
['app', [iframe('a'), iframe('b')]],
64-
['web', [iframe('c'), iframe('d')]],
64+
['web', [iframe('c'), iframe('d'), iframe('e')]],
6565
]
6666
const { visible, overflow } = docksSplitGroupsWithCapacity(groups, 3)
6767
expect(visible).toEqual([['app', [iframe('a'), iframe('b')]], ['web', [iframe('c')]]])
68-
expect(overflow).toEqual([['web', [iframe('d')]]])
68+
expect(overflow).toEqual([['web', [iframe('d'), iframe('e')]]])
6969
})
7070

71-
it('leaves a single overflowing entry in overflow by default', () => {
71+
it('folds a lone overflowing entry back into visible instead of leaving it in overflow', () => {
7272
const groups: DevToolsDockEntriesGrouped = [['default', [iframe('a'), iframe('b'), iframe('c')]]]
7373
const { visible, overflow } = docksSplitGroupsWithCapacity(groups, 2)
74-
expect(visible).toEqual([['default', [iframe('a'), iframe('b')]]])
75-
expect(overflow).toEqual([['default', [iframe('c')]]])
76-
})
77-
78-
it('foldSingleOverflow folds a lone overflowing entry back into visible', () => {
79-
const groups: DevToolsDockEntriesGrouped = [['default', [iframe('a'), iframe('b'), iframe('c')]]]
80-
const { visible, overflow } = docksSplitGroupsWithCapacity(groups, 2, { foldSingleOverflow: true })
8174
expect(visible).toEqual([['default', [iframe('a'), iframe('b')]], ['default', [iframe('c')]]])
8275
expect(overflow).toEqual([])
8376
})
8477

85-
it('foldSingleOverflow leaves two or more overflowing entries alone', () => {
78+
it('leaves two or more overflowing entries as overflow', () => {
8679
const groups: DevToolsDockEntriesGrouped = [['default', [iframe('a'), iframe('b'), iframe('c'), iframe('d')]]]
87-
const { visible, overflow } = docksSplitGroupsWithCapacity(groups, 2, { foldSingleOverflow: true })
80+
const { visible, overflow } = docksSplitGroupsWithCapacity(groups, 2)
8881
expect(visible).toEqual([['default', [iframe('a'), iframe('b')]]])
8982
expect(overflow).toEqual([['default', [iframe('c'), iframe('d')]]])
9083
})
9184

92-
it('foldSingleOverflow is a no-op when nothing overflows', () => {
85+
it('is a no-op when nothing overflows', () => {
9386
const groups: DevToolsDockEntriesGrouped = [['default', [iframe('a'), iframe('b')]]]
94-
const { visible, overflow } = docksSplitGroupsWithCapacity(groups, 2, { foldSingleOverflow: true })
87+
const { visible, overflow } = docksSplitGroupsWithCapacity(groups, 2)
9588
expect(visible).toEqual(groups)
9689
expect(overflow).toEqual([])
9790
})

packages/core/src/client/webcomponents/state/dock-settings.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -406,18 +406,16 @@ export function deriveSidebarCapacity(options: SidebarCapacityOptions): number {
406406
/**
407407
* Split grouped entries into visible and overflow based on capacity.
408408
*
409-
* With `foldSingleOverflow`, a lone overflowing entry is folded back into
410-
* `visible` instead — a whole overflow affordance (button + badge + popover)
411-
* just to reveal one icon costs more chrome than it saves, so that one entry
412-
* renders inline in the slot the affordance would have occupied. Folding only
409+
* A lone overflowing entry folds back into `visible` instead of staying in
410+
* `overflow` — a whole overflow affordance (button + badge + popover) just to
411+
* reveal one icon costs more chrome than it saves, so that one entry renders
412+
* inline in the slot the affordance would have occupied. Folding only
413413
* triggers for exactly one overflowing entry; two or more still overflow
414-
* normally. Off by default so callers with their own overflow affordance
415-
* semantics (e.g. the group sidebar's "show more" rail button) are unaffected.
414+
* normally.
416415
*/
417416
export function docksSplitGroupsWithCapacity(
418417
groups: DevToolsDockEntriesGrouped,
419418
capacity: number,
420-
options?: { foldSingleOverflow?: boolean },
421419
): SplitGroupsResult {
422420
const visible: DevToolsDockEntriesGrouped = []
423421
const overflow: DevToolsDockEntriesGrouped = []
@@ -438,7 +436,7 @@ export function docksSplitGroupsWithCapacity(
438436
}
439437
}
440438

441-
if (options?.foldSingleOverflow && overflow.reduce((acc, [, items]) => acc + items.length, 0) === 1)
439+
if (overflow.reduce((acc, [, items]) => acc + items.length, 0) === 1)
442440
return { visible: [...visible, ...overflow], overflow: [] }
443441

444442
return { visible, overflow }

0 commit comments

Comments
 (0)