Skip to content

Commit 278e516

Browse files
authored
Always render section headers in RSP for dividers (#6535)
1 parent 12cb303 commit 278e516

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/@react-spectrum/listbox/src/ListBoxBase.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ export function useListBoxLayout<T>(state: ListState<T>): ListLayout<T> {
5858
padding: scale === 'large' ? 5 : 4, // TODO: get from DNA
5959
loaderHeight: 40,
6060
placeholderHeight: scale === 'large' ? 48 : 32,
61-
collator
61+
collator,
62+
forceSectionHeaders: true
6263
})
6364
, [collator, scale]);
6465

packages/@react-stately/layout/src/ListLayout.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ export type ListLayoutOptions<T> = {
2525
collator?: Intl.Collator,
2626
loaderHeight?: number,
2727
placeholderHeight?: number,
28-
allowDisabledKeyFocus?: boolean
28+
allowDisabledKeyFocus?: boolean,
29+
forceSectionHeaders?: boolean
2930
};
3031

3132
// A wrapper around LayoutInfo that supports hierarchy
@@ -59,6 +60,7 @@ export class ListLayout<T> extends Layout<Node<T>, ListLayoutProps> implements K
5960
protected estimatedRowHeight: number;
6061
protected headingHeight: number;
6162
protected estimatedHeadingHeight: number;
63+
protected forceSectionHeaders: boolean;
6264
protected padding: number;
6365
protected indentationForItem?: (collection: Collection<Node<T>>, key: Key) => number;
6466
protected layoutInfos: Map<Key, LayoutInfo>;
@@ -88,6 +90,7 @@ export class ListLayout<T> extends Layout<Node<T>, ListLayoutProps> implements K
8890
this.estimatedRowHeight = options.estimatedRowHeight;
8991
this.headingHeight = options.headingHeight;
9092
this.estimatedHeadingHeight = options.estimatedHeadingHeight;
93+
this.forceSectionHeaders = options.forceSectionHeaders;
9194
this.padding = options.padding || 0;
9295
this.indentationForItem = options.indentationForItem;
9396
this.collator = options.collator;
@@ -310,7 +313,7 @@ export class ListLayout<T> extends Layout<Node<T>, ListLayoutProps> implements K
310313
buildSection(node: Node<T>, x: number, y: number): LayoutNode {
311314
let width = this.virtualizer.visibleRect.width;
312315
let header = null;
313-
if (node.rendered) {
316+
if (node.rendered || this.forceSectionHeaders) {
314317
let headerNode = this.buildHeader(node, x, y);
315318
header = headerNode.layoutInfo;
316319
header.key += ':header';

0 commit comments

Comments
 (0)