@atlaskit/page-layout
Version:
A collection of components which let you compose an application's page layout.
39 lines (38 loc) • 1.23 kB
JavaScript
import { useContext, useEffect } from 'react';
import { SidebarResizeContext } from './sidebar-resize-context';
/**
* _**WARNING:**_ This hook is intended as a temporary solution and
* is likely to be removed in a future version of page-layout.
*
* ---
*
* This hook will prevent the left sidebar from automatically collapsing
* when it is in a flyout state.
*
* The intended use case for this hook is to allow popup menus in the
* left sidebar to be usable while it is in a flyout state.
*
* ## Usage
* The intended usage is to use this hook within the popup component
* you are rendering. This way the left sidebar will be locked for
* as long as the popup is open.
*
* @deprecated `@atlaskit/page-layout` is deprecated. Use `@atlaskit/navigation-system` instead.
*/
export const useLeftSidebarFlyoutLock = () => {
const {
setLeftSidebarState
} = useContext(SidebarResizeContext);
useEffect(() => {
setLeftSidebarState(current => ({
...current,
flyoutLockCount: current.flyoutLockCount + 1
}));
return () => {
setLeftSidebarState(current => ({
...current,
flyoutLockCount: current.flyoutLockCount - 1
}));
};
}, [setLeftSidebarState]);
};