37
Views
2
Comments
Reactive Sidebar Refreshes Unintentionally on Page Navigation
Application Type
Reactive

Hi everyone,

I'm working on an OutSystems project where I've created a collapsible sidebar that opens and closes with a button. The sidebar is implemented as a web block and placed on every page, allowing consistent functionality across the app. Here’s a quick breakdown of how it works:

  1. Sidebar Button: Located in the bottom-right corner of the sidebar, this button triggers an action to open/close the sidebar.

Open:


Closed:


  1. Action Logic: The action first checks if the sidebar is open. If it’s open, it closes it; if it’s closed, it opens it. The action then triggers an event that calls a client action to manage the sidebar’s visibility.
  2. Client Action (OnToggleSidebarEvent): This client action adjusts the screensize based on the open/close state.

The issue arises when I click an item within the sidebar (that sits in an item list) that redirects to a new URL. The item is based on a static entity called "MenuBarData"  This causes the entire sidebar to refresh, leading to a "spacey" look as it reinitializes on the new page. Which has the following attribute:

  • Id
  • Label
  • Order
  • IsActive
  • Page
  • IconURL


It redirects to the URL given in the Page Attribute


This is not the desired behavior, as it should ideally maintain its state without appearing to refresh.


I also dropped a zip file "Bestanden" with a video which shows the behavior and the oml file.


Question: How can I prevent the sidebar from refreshing or reloading when navigating to a new page? Is there a way to maintain its open/closed state seamlessly across page navigations?

Any help or guidance would be greatly appreciated!

Bestanden.zip
2019-01-31 08-54-57
André Costa
Champion

Hi @Piet Pieper 

What I think is wrong is that when you navigate to a new URL, your SideBar is always closed because it always assumes the default value (false). 

A possible solution is to store the state of the sidebar in a client variable IsSideBarOpen and assign it in your OpenSidebarOnClick action whenever you open or close the sidebar.

When navigation to a new screen, you need to build the logic that if the client variable IsSideBarOpen = True, then you execute the SidebarOpen action.

Hope this helps

UserImage.jpg
Piet Pieper

I already do that, i store the IsSideBarOpen in a client variable and OnItialize of loading a new page i do this:

ScreenSize = If(Client.isSidebarOpen, "280px;", "45px;")


The reason for that is that when having the sidebar open or closed i want the page to move with it, i do not want to sidebar to be on top of the page but to make the page smaller when collapsed open and make the page bigger when closed.


The sidebar is in a webblock and using an event i tell the page if its open or closed. You can see in the OML.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.