-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove sticky-menu class preventing full admin page scroll (#11308)
* Remove sticky-menu class preventing full admin page scroll Gutenberg adds ‘is-fullscreen-mode’ to the page body class, causing WordPress to add ‘sticky-menu’. This prevents the page being vertically scrolled, cutting off long admin menus. Remove ‘sticky-menu’ as part of the FullscreenMode setup * Restore sticky-menu class if it previously existed In case it was added for a legitimate reason originally. * Add unit test for fullscreenmode component
- Loading branch information
1 parent
cc91689
commit a356318
Showing
2 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
packages/edit-post/src/components/fullscreen-mode/test/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { shallow } from 'enzyme'; | ||
|
||
/** | ||
* Internal dependencies. | ||
*/ | ||
import { FullscreenMode } from '..'; | ||
|
||
describe( 'FullscreenMode', () => { | ||
it( 'fullscreen mode to be added to document body when active', () => { | ||
shallow( <FullscreenMode isActive={ true } /> ); | ||
|
||
expect( document.body.classList.contains( 'is-fullscreen-mode' ) ).toBe( true ); | ||
} ); | ||
|
||
it( 'fullscreen mode not to be added to document body when active', () => { | ||
shallow( <FullscreenMode isActive={ false } /> ); | ||
|
||
expect( document.body.classList.contains( 'is-fullscreen-mode' ) ).toBe( false ); | ||
} ); | ||
|
||
it( 'sticky-menu to be removed from the body class if present', () => { | ||
document.body.classList.add( 'sticky-menu' ); | ||
|
||
shallow( <FullscreenMode isActive={ false } /> ); | ||
|
||
expect( document.body.classList.contains( 'sticky-menu' ) ).toBe( false ); | ||
} ); | ||
|
||
it( 'sticky-menu to be restored when component unmounted and originally present', () => { | ||
document.body.classList.add( 'sticky-menu' ); | ||
|
||
const mode = shallow( <FullscreenMode isActive={ false } /> ); | ||
mode.unmount(); | ||
|
||
expect( document.body.classList.contains( 'sticky-menu' ) ).toBe( true ); | ||
} ); | ||
} ); |