Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: DetailsList is still tabbable when header is not visible",
"packageName": "@fluentui/react",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,9 @@ const DetailsListInner: React.ComponentType<IDetailsListInnerProps> = (

const rowRole = role === defaultRole ? undefined : 'presentation';

// add tabindex="0" to first row if no header exists, to ensure the focuszone is in the tab order
const rowFocusZoneProps = isHeaderVisible || index > 0 ? {} : { tabIndex: 0 };

const rowProps: IDetailsRowProps = {
item: item,
itemIndex: index,
Expand Down Expand Up @@ -520,6 +523,7 @@ const DetailsListInner: React.ComponentType<IDetailsListInnerProps> = (
useFastIcons,
role: rowRole,
isGridRow: true,
focusZoneProps: rowFocusZoneProps,
};

if (!item) {
Expand Down
10 changes: 10 additions & 0 deletions packages/react/src/components/DetailsList/DetailsList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1077,4 +1077,14 @@ describe('DetailsList', () => {
const groupNameId = checkbox.getAttribute('aria-labelledby')?.split(' ')[1];
expect(container.querySelector(`#${groupNameId} span`)!.textContent).toEqual('Group 0');
});

it('makes the first row tabbable if isHeaderVisible is false', () => {
const component = renderer.create(
<DetailsList items={mockData(5)} columns={mockData(5, true)} isHeaderVisible={false} />,
);

const firstRow = component.root.findAllByType(DetailsRow)[0];

expect(firstRow.props.focusZoneProps?.tabIndex).toEqual(0);
});
});