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
11 changes: 7 additions & 4 deletions packages/react/src/navigation-menu/list/NavigationMenuList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ export const NavigationMenuList = React.forwardRef(function NavigationMenuList(
// but we want to block it in this case.
// When nested, skip this handler so arrow keys can reach the parent CompositeRoot.
const defaultProps: HTMLProps = nested
? {
'aria-orientation': orientation,
}
? EMPTY_OBJECT
: {
onKeyDown(event: React.KeyboardEvent<HTMLDivElement>) {
const shouldStop =
Expand All @@ -82,7 +80,12 @@ export const NavigationMenuList = React.forwardRef(function NavigationMenuList(
},
};

const props = [dismissProps?.floating || EMPTY_OBJECT, defaultProps, elementProps];
const props = [
dismissProps?.floating || EMPTY_OBJECT,
defaultProps,
{ 'aria-orientation': undefined },
elementProps,
];

// When nested, skip the CompositeRoot wrapper so that triggers can participate
// in the parent Content's composite navigation context. Also skip the onKeyDown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -831,18 +831,18 @@ describe('<NavigationMenu.Root />', () => {
},
}));

it('applies aria-orientation to the top-level list instead of the root element', async () => {
it('does not apply aria-orientation to the top-level list or root element', async () => {
await render(<TestNavigationMenuOrientationAttributes />);

expect(screen.getByTestId('top-level-root')).not.toHaveAttribute('aria-orientation');
expect(screen.getByTestId('top-level-list')).toHaveAttribute('aria-orientation', 'vertical');
expect(screen.getByTestId('top-level-list')).not.toHaveAttribute('aria-orientation');
});

it('applies aria-orientation to nested lists instead of nested root elements', async () => {
it('does not apply aria-orientation to nested lists or root elements', async () => {
await render(<TestNavigationMenuOrientationAttributes />);

expect(screen.getByTestId('nested-root')).not.toHaveAttribute('aria-orientation');
expect(screen.getByTestId('nested-list')).toHaveAttribute('aria-orientation', 'vertical');
expect(screen.getByTestId('nested-list')).not.toHaveAttribute('aria-orientation');
});

describe('interactions', () => {
Expand Down
Loading