Skip to content

Commit

Permalink
Remove fullscreen if component unmounted (#156)
Browse files Browse the repository at this point in the history
* Remove fullscreen if component unmounted

It’s marked for removal anyway, but this fixes the fullscreen class remaining if the component is unmounted before fullscreen is disabled

* Fix up linting
  • Loading branch information
johngodley authored Jun 16, 2022
1 parent a1895fc commit f1fa8f7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/block-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,21 @@ function BlockEditor( props ) {

// For back-compat with older iso-editor
useEffect( () => {
const html = document.querySelector( 'html' );

if ( isFullscreenActive ) {
// @ts-ignore
document.querySelector( 'html' ).classList.add( 'is-fullscreen-mode' );
html.classList.add( 'is-fullscreen-mode' );
} else {
// @ts-ignore
document.querySelector( 'html' ).classList.remove( 'is-fullscreen-mode' );
html.classList.remove( 'is-fullscreen-mode' );
}

return () => {
if ( html ) {
html.classList.remove( 'is-fullscreen-mode' );
}
};
}, [ isFullscreenActive ] );

return (
Expand Down

0 comments on commit f1fa8f7

Please sign in to comment.