Skip to content

Commit

Permalink
[TreeView] Remove un-needed aria-activedescendant attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
flaviendelangle committed Apr 22, 2024
1 parent 4b07dfd commit ce54e89
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 20 deletions.
8 changes: 2 additions & 6 deletions packages/x-tree-view/src/TreeItem/TreeItem.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,13 @@ describe('<TreeItem />', () => {
});

it('should be able to use a custom id', () => {
const { getByRole, getByTestId } = render(
const { getByRole } = render(
<SimpleTreeView>
<TreeItem id="customId" itemId="one" data-testid="one" />
</SimpleTreeView>,
);

act(() => {
getByTestId('one').focus();
});

expect(getByRole('tree')).to.have.attribute('aria-activedescendant', 'customId');
expect(getByRole('treeitem')).to.have.attribute('id', 'customId');
});

describe('Accessibility', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,9 @@ export const useTreeViewFocus: TreeViewPlugin<UseTreeViewFocusSignature> = ({
}
};

const focusedItem = instance.getItemMeta(state.focusedItemId!);
const activeDescendant = focusedItem
? instance.getTreeItemIdAttribute(focusedItem.id, focusedItem.idAttribute)
: null;

return {
getRootProps: (otherHandlers) => ({
onFocus: createRootHandleFocus(otherHandlers),
'aria-activedescendant': activeDescendant ?? undefined,
}),
publicAPI: {
focusItem,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,7 @@ export type UseTreeViewDefaultizedParameters<
export interface UseTreeViewRootSlotProps
extends Pick<
React.HTMLAttributes<HTMLUListElement>,
| 'onFocus'
| 'onBlur'
| 'onKeyDown'
| 'id'
| 'aria-activedescendant'
| 'aria-multiselectable'
| 'role'
| 'tabIndex'
'onFocus' | 'onBlur' | 'onKeyDown' | 'id' | 'aria-multiselectable' | 'role' | 'tabIndex'
> {
ref: React.Ref<HTMLUListElement>;
}
Expand Down

0 comments on commit ce54e89

Please sign in to comment.