openstax / os-webview

:books: Front-end web application for the OpenStax web site
28 stars 3 forks source link

Fix menu flicker #2658

Closed RoyEJohnson closed 1 week ago

RoyEJohnson commented 1 month ago

DISCO-433 Separated Header and Footer from the changing content in DefaultLayout so that the whole thing isn't destroyed and re-created on every navigation. Currently, every ImportedPage is a DefaultLayout, so it's pretty easy. Depending on what future layouts are like, we may want to make the Header/Footer conceptually distinct from the layout.

RoyEJohnson commented 1 month ago

This is currently installed on Dev.

RoyEJohnson commented 1 month ago

I had missed the way Fallback is done, so thought everything was a DefaultLayout somehow. Updated code (on Dev) seems to work pretty well. Still flickers between home page and other pages, but otherwise the wrapper generally persists. The b2s page is not wrapped.

RoyEJohnson commented 1 month ago

I made it so that ImportedPage always applies the Layout. The content components set parameters for the Layout component, but don't apply layouts themselves. This has made the menus stable except when coming to and from the home page. I don't know what causes it to redraw menus. I'll keep looking, but it may need to be a problem for another day. It's certainly better than what's on staging now.

The layout parameters default to the default layout, so only the flex page actually has to set it.

RoyEJohnson commented 2 weeks ago

@TomWoodward I have pulled the Layout up another level to wrap around the Routes. I also extracted it to a Context. The higher level and some careful handling of data changes keep the menus from re-rendering. It is ready to review.