Skip to content

Commit

Permalink
FullscreenMode: remove the is-fullscreen-mode CSS class from body on …
Browse files Browse the repository at this point in the history
…unmount (#26103)
  • Loading branch information
jsnajdr authored Oct 14, 2020
1 parent c0e8588 commit 8ff4794
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/interface/src/components/fullscreen-mode/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export class FullscreenMode extends Component {
if ( this.isSticky ) {
document.body.classList.add( 'sticky-menu' );
}

if ( this.props.isActive ) {
document.body.classList.remove( 'is-fullscreen-mode' );
}
}

componentDidUpdate( prevProps ) {
Expand Down
21 changes: 21 additions & 0 deletions packages/interface/src/components/fullscreen-mode/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,25 @@ describe( 'FullscreenMode', () => {
true
);
} );

it( 'fullscreen mode to be removed from document body when component unmounted', () => {
// not present initially
expect( document.body.classList.contains( 'is-fullscreen-mode' ) ).toBe(
false
);

const mode = shallow( <FullscreenMode isActive /> );

// present after mounting with `isActive`
expect( document.body.classList.contains( 'is-fullscreen-mode' ) ).toBe(
true
);

mode.unmount();

// removed after unmounting
expect( document.body.classList.contains( 'is-fullscreen-mode' ) ).toBe(
false
);
} );
} );

0 comments on commit 8ff4794

Please sign in to comment.