Skip to content

Commit 769cbb0

Browse files
authored
fix: gridlist section accessibility updates (#8932)
* fix: gridlist section accessibility updates pt2 * remove unused import
1 parent 02cc874 commit 769cbb0

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

packages/react-aria-components/src/GridList.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {DragAndDropHooks} from './useDragAndDrop';
2020
import {DraggableCollectionState, DroppableCollectionState, Collection as ICollection, ListState, Node, SelectionBehavior, UNSTABLE_useFilteredListState, useListState} from 'react-stately';
2121
import {filterDOMProps, inertValue, LoadMoreSentinelProps, useLoadMoreSentinel, useObjectRef} from '@react-aria/utils';
2222
import {forwardRefType, GlobalDOMAttributes, HoverEvents, Key, LinkDOMProps, PressEvents, RefObject} from '@react-types/shared';
23-
import {HeaderContext} from './Header';
2423
import {ListStateContext} from './ListBox';
2524
import React, {createContext, ForwardedRef, forwardRef, HTMLAttributes, JSX, ReactNode, useContext, useEffect, useMemo, useRef} from 'react';
2625
import {SelectionIndicatorContext} from './SelectionIndicator';
@@ -579,11 +578,11 @@ export interface GridListSectionProps<T> extends SectionProps<T> {}
579578
/**
580579
* A GridListSection represents a section within a GridList.
581580
*/
582-
export const GridListSection = /*#__PURE__*/ createBranchComponent(SectionNode, <T extends object>(props: GridListSectionProps<T>, ref: ForwardedRef<HTMLElement>, item: Node<T>) => {
581+
export const GridListSection = /*#__PURE__*/ createBranchComponent(SectionNode, <T extends object>(props: GridListSectionProps<T>, ref: ForwardedRef<HTMLDivElement>, item: Node<T>) => {
583582
let state = useContext(ListStateContext)!;
584583
let {CollectionBranch} = useContext(CollectionRendererContext);
585584
let headingRef = useRef(null);
586-
ref = useObjectRef<HTMLElement>(ref);
585+
ref = useObjectRef<HTMLDivElement>(ref);
587586
let {rowHeaderProps, rowProps, rowGroupProps} = useGridListSection({
588587
'aria-label': props['aria-label'] ?? undefined
589588
}, state, ref);
@@ -598,33 +597,34 @@ export const GridListSection = /*#__PURE__*/ createBranchComponent(SectionNode,
598597
delete DOMProps.id;
599598

600599
return (
601-
<section
600+
<div
602601
{...mergeProps(DOMProps, renderProps, rowGroupProps)}
603602
ref={ref}>
604603
<Provider
605604
values={[
606-
[HeaderContext, {...rowProps, ref: headingRef}],
607-
[GridListHeaderContext, {...rowHeaderProps}]
605+
[GridListHeaderContext, {...rowProps, ref: headingRef}],
606+
[GridListHeaderInnerContext, {...rowHeaderProps}]
608607
]}>
609608
<CollectionBranch
610609
collection={state.collection}
611610
parent={item} />
612611
</Provider>
613-
</section>
612+
</div>
614613
);
615614
});
616615

617-
const GridListHeaderContext = createContext<HTMLAttributes<HTMLElement> | null>(null);
616+
export const GridListHeaderContext = createContext<ContextValue<HTMLAttributes<HTMLDivElement>, HTMLDivElement>>({});
617+
const GridListHeaderInnerContext = createContext<HTMLAttributes<HTMLElement> | null>(null);
618618

619-
export const GridListHeader = /*#__PURE__*/ createLeafComponent(HeaderNode, function Header(props: HTMLAttributes<HTMLElement>, ref: ForwardedRef<HTMLElement>) {
620-
[props, ref] = useContextProps(props, ref, HeaderContext);
621-
let rowHeaderProps = useContext(GridListHeaderContext);
619+
export const GridListHeader = /*#__PURE__*/ createLeafComponent(HeaderNode, function Header(props: HTMLAttributes<HTMLElement>, ref: ForwardedRef<HTMLDivElement>) {
620+
[props, ref] = useContextProps(props, ref, GridListHeaderContext);
621+
let rowHeaderProps = useContext(GridListHeaderInnerContext);
622622

623623
return (
624-
<header className="react-aria-GridListHeader" ref={ref} {...props}>
624+
<div className="react-aria-GridListHeader" ref={ref} {...props}>
625625
<div {...rowHeaderProps} style={{display: 'contents'}}>
626626
{props.children}
627627
</div>
628-
</header>
628+
</div>
629629
);
630630
});

packages/react-aria-components/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export {DropZone, DropZoneContext} from './DropZone';
3939
export {FieldError, FieldErrorContext} from './FieldError';
4040
export {FileTrigger} from './FileTrigger';
4141
export {Form, FormContext} from './Form';
42-
export {GridListLoadMoreItem, GridList, GridListItem, GridListContext, GridListHeader, GridListSection} from './GridList';
42+
export {GridListLoadMoreItem, GridList, GridListItem, GridListContext, GridListHeader, GridListHeaderContext, GridListSection} from './GridList';
4343
export {Group, GroupContext} from './Group';
4444
export {Header, HeaderContext} from './Header';
4545
export {Heading} from './Heading';

0 commit comments

Comments
 (0)