Skip to content

Commit

Permalink
[Popover] Fix inert attribute (mui#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
atomiks authored Oct 9, 2024
1 parent 1b40ac9 commit cab77be
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import * as React from 'react';
import * as Popover from '@base_ui/react/Popover';
import { createRenderer, describeConformance } from '#test-utils';
import { screen } from '@mui/internal-test-utils';
import { expect } from 'chai';

describe('<Popover.Positioner />', () => {
const { render } = createRenderer();
Expand All @@ -15,4 +17,26 @@ describe('<Popover.Positioner />', () => {
);
},
}));

describe('prop: keepMounted', () => {
it('has inert attribute when closed', async () => {
await render(
<Popover.Root animated={false}>
<Popover.Positioner keepMounted data-testid="positioner" />
</Popover.Root>,
);

expect(screen.getByTestId('positioner')).to.have.attribute('inert');
});

it('does not have inert attribute when open', async () => {
await render(
<Popover.Root open animated={false}>
<Popover.Positioner keepMounted data-testid="positioner" />
</Popover.Root>,
);

expect(screen.getByTestId('positioner')).not.to.have.attribute('inert');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export function usePopoverPositioner(
return mergeReactProps<'div'>(externalProps, {
role: 'presentation',
// @ts-ignore
inert: getInertValue(open),
inert: getInertValue(!open),
style: {
...positionerStyles,
...hiddenStyles,
Expand Down

0 comments on commit cab77be

Please sign in to comment.