Skip to content

Commit

Permalink
fix: reset initialsidebar after shouldDisplaySidebarOpen (#1428)
Browse files Browse the repository at this point in the history
* fix: reset initialsidebar after shouldDisplaySidebarOpen

* fix: fixed issue due to localstorage sidebar value when shifting from old to new one
  • Loading branch information
sundasnoreen12 authored Aug 2, 2024
1 parent 3a54276 commit 26199fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/courseware/course/new-sidebar/Sidebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 4 additions & 0 deletions src/courseware/course/new-sidebar/SidebarContextProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 26199fa

Please sign in to comment.