fix: reset initialsidebar after shouldDisplaySidebarOpen (#1428)
* fix: reset initialsidebar after shouldDisplaySidebarOpen * fix: fixed issue due to localstorage sidebar value when shifting from old to new one
This commit is contained in:
@@ -6,7 +6,8 @@ import { SIDEBARS } from './sidebars';
|
||||
const Sidebar = () => {
|
||||
const { currentSidebar, isDiscussionbarAvailable, isNotificationbarAvailable } = useContext(SidebarContext);
|
||||
|
||||
if (currentSidebar === null || (!isDiscussionbarAvailable && !isNotificationbarAvailable)) { return null; }
|
||||
if (currentSidebar === null || (!isDiscussionbarAvailable && !isNotificationbarAvailable)
|
||||
|| !SIDEBARS[currentSidebar]) { return null; }
|
||||
const SidebarToRender = SIDEBARS[currentSidebar].Sidebar;
|
||||
|
||||
return (
|
||||
|
||||
@@ -61,6 +61,10 @@ const SidebarProvider = ({
|
||||
}
|
||||
}, [hideDiscussionbar, hideNotificationbar]);
|
||||
|
||||
useEffect(() => {
|
||||
setCurrentSidebar(initialSidebar);
|
||||
}, [shouldDisplaySidebarOpen, initialSidebar]);
|
||||
|
||||
const handleWidgetToggle = useCallback((widgetId, sidebarId) => {
|
||||
setHideDiscussionbar(prevWidgetId => (widgetId === WIDGETS.DISCUSSIONS ? true : prevWidgetId));
|
||||
setHideNotificationbar(prevWidgetId => (widgetId === WIDGETS.NOTIFICATIONS ? true : prevWidgetId));
|
||||
|
||||
Reference in New Issue
Block a user