Skip to content

Commit

Permalink
Mobile Web: Ensure that sidebar is closed on the first visit
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Oct 11, 2019
1 parent 4c68cb2 commit e78d12d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import {
* @return {null} This is a data component so does not render any ui.
*/
export default function( { postId } ) {
useAdjustSidebarListener( postId );
useBlockSelectionListener( postId );
useAdjustSidebarListener( postId );
useUpdatePostLinkListener( postId );
const { triggerGuide } = useDispatch( 'core/nux' );
useEffect( () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const useAdjustSidebarListener = ( postId ) => {

const { openGeneralSidebar, closeGeneralSidebar } = useDispatch( STORE_KEY );

const previousIsSmall = useRef( isSmall );
const previousIsSmall = useRef( null );
const sidebarToReOpenOnExpand = useRef( null );

useEffect( () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,10 @@ describe( 'listener hook tests', () => {
getSpyedFunction( STORE_KEY, 'closeGeneralSidebar' )
).not.toHaveBeenCalled();
} );
it( 'does not close sidebar if viewport is small and there is an active ' +
it( 'closes sidebar if viewport is small and there is an active ' +
'sidebar name available on initial render', () => {
setMockReturnValue( 'core/viewport', 'isViewportMatch', true );
setMockReturnValue( STORE_KEY, 'getActiveGeneralSidebarName', 'foo' );
// initial render does nothing (and sidebar will be closed already)
act( () => {
renderComponent( useAdjustSidebarListener, 10 );
} );
Expand All @@ -150,7 +149,7 @@ describe( 'listener hook tests', () => {
).not.toHaveBeenCalled();
expect(
getSpyedFunction( STORE_KEY, 'closeGeneralSidebar' )
).not.toHaveBeenCalled();
).toHaveBeenCalled();
} );
it( 'closes sidebar if viewport is small and there is an active ' +
'sidebar name available when viewport size changes', () => {
Expand Down

0 comments on commit e78d12d

Please sign in to comment.