Skip to content

Commit

Permalink
rename css class Drawer__body--open to Drawer--open
Browse files Browse the repository at this point in the history
  • Loading branch information
domschab23 committed Feb 26, 2024
1 parent 2df40f1 commit c82a0db
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
6 changes: 3 additions & 3 deletions src/Drawer/Drawer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ const Drawer = ({
useEffect(() => {
// isCurrentlyOpen ref accounts for a case where you could have multiple drawers
// on one page and you try to access one of them via their url. Without using ref, the
// Drawer__Body--open would be potentially removed via other
// Drawer--open would be potentially removed via other
// closed drawer because of a race condition
function disableBackgroundScrolling() {
if (visible && !isCurrentlyOpen.current) {
document.body.classList.add('Drawer__Body--open');
document.body.classList.add('Drawer--open');
isCurrentlyOpen.current = true;
}

if (!visible && isCurrentlyOpen.current) {
document.body.classList.remove('Drawer__Body--open');
document.body.classList.remove('Drawer--open');
isCurrentlyOpen.current = false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Drawer/Drawer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
display: flex;
flex-direction: column;

&__Body--open {
&--open {
overflow: hidden;
}

Expand Down
36 changes: 18 additions & 18 deletions src/Drawer/Drawer.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ describe('Drawer', () => {
expect(onRequestClose).not.toHaveBeenCalled();
});

it('body tag does not have Drawer__Body--open', () => {
it('body tag does not have Drawer--open', () => {
const { container } = render(<SetupDrawerWithChildren visible={false} />);
const body = container.closest('body');

expect(body.classList).not.toContain('Drawer__Body--open');
expect(body.classList).not.toContain('Drawer--open');
});

describe('when hasBackgroundOverlay is false', () => {
Expand All @@ -158,12 +158,12 @@ describe('Drawer', () => {
expect(elements.drawerOverlay.query()).not.toBeInTheDocument();
});

it('body tag does not have Drawer__Body--open', () => {
it('body tag does not have Drawer--open', () => {
// eslint-disable-next-line max-len
const { container } = render(<SetupDrawerWithChildren hasBackgroundOverlay={false} visible={false} />);
const body = container.closest('body');

expect(body.classList).not.toContain('Drawer__Body--open');
expect(body.classList).not.toContain('Drawer--open');
});
});
});
Expand Down Expand Up @@ -198,11 +198,11 @@ describe('Drawer', () => {
expect(onRequestClose).toHaveBeenCalled();
});

it('body tag has Drawer__Body--open', () => {
it('body tag has Drawer--open', () => {
const { container } = render(<SetupDrawerWithChildren visible />);
const body = container.closest('body');

expect(body.classList).toContain('Drawer__Body--open');
expect(body.classList).toContain('Drawer--open');
});

describe('when hasBackgroundOverlay is false', () => {
Expand All @@ -212,58 +212,58 @@ describe('Drawer', () => {
expect(elements.drawerOverlay.query()).not.toBeInTheDocument();
});

it('body tag does not have Drawer__Body--open', () => {
it('body tag does not have Drawer--open', () => {
// eslint-disable-next-line max-len
const { container } = render(<SetupDrawerWithChildren hasBackgroundOverlay={false} visible />);
const body = container.closest('body');

expect(body.classList).not.toContain('Drawer__Body--open');
expect(body.classList).not.toContain('Drawer--open');
});
});
});
});

describe('When component renders multiple Drawers', () => {
describe('with drawerOne visible by default', () => {
it('body tag has Drawer__Body--open', () => {
it('body tag has Drawer--open', () => {
const { container } = render(<SetupMultipleDrawers drawerOneVisibleDefault />);
const body = container.closest('body');

expect(body.classList).toContain('Drawer__Body--open');
expect(body.classList).toContain('Drawer--open');
});

describe('when user clicks on drawerOne toggle visibility button', () => {
it('body tag does not have Drawer__body--open after click', () => {
it('body tag does not have Drawer--open after click', () => {
const { container } = render(<SetupMultipleDrawers drawerOneVisibleDefault />);
const body = container.closest('body');

expect(body.classList).toContain('Drawer__Body--open');
expect(body.classList).toContain('Drawer--open');

userEvent.click(elements.drawerOneToggleVisibilityButton.get());

expect(body.classList).not.toContain('Drawer__Body--open');
expect(body.classList).not.toContain('Drawer--open');
});
});
});

describe('with no drawers visible by default', () => {
it('body tag does not have Drawer__body--open', () => {
it('body tag does not have Drawer--open', () => {
const { container } = render(<SetupMultipleDrawers />);
const body = container.closest('body');

expect(body.classList).not.toContain('Drawer__Body--open');
expect(body.classList).not.toContain('Drawer--open');
});

describe('when user clicks on drawerOne toggle visibility button', () => {
it('body tag has Drawer__body--open after click', () => {
it('body tag has Drawer--open after click', () => {
const { container } = render(<SetupMultipleDrawers />);
const body = container.closest('body');

expect(body.classList).not.toContain('Drawer__Body--open');
expect(body.classList).not.toContain('Drawer--open');

userEvent.click(elements.drawerOneToggleVisibilityButton.get());

expect(body.classList).toContain('Drawer__Body--open');
expect(body.classList).toContain('Drawer--open');
});
});
});
Expand Down

0 comments on commit c82a0db

Please sign in to comment.