Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable mobile sidebar from REDUX_REHYDRATE payload. #4283

Closed
wants to merge 1 commit into from

Conversation

jorgefilipecosta
Copy link
Member

The mobile sidebar should be closed on reload even if it was opened before. This behavior was implemented, but during a refactor to the sidebars a regression made the logic invalid.

How Has This Been Tested?

Resize to mobile resolutions, open the sidebar, reload the page, and see the sidebar is now closed.
Try to open and close sidebar in desktop and mobile see that things still work.
See that on the desktop the sidebar opened state is still persisted when reloading.

@jorgefilipecosta jorgefilipecosta force-pushed the fix/disable-mobile-sidebar branch from c0b7366 to 5284172 Compare January 4, 2018 12:50
Mobile sidebar should be closed on reload even if it was opened before.
@jorgefilipecosta jorgefilipecosta force-pushed the fix/disable-mobile-sidebar branch from 5284172 to 20bca52 Compare January 4, 2018 12:51
@jorgefilipecosta jorgefilipecosta added [Type] Bug An existing feature does not function as intended Mobile Web Viewport sizes for mobile and tablet devices labels Jan 4, 2018
@jorgefilipecosta jorgefilipecosta self-assigned this Jan 4, 2018
@youknowriad
Copy link
Contributor

Nothing that in #4248 we want to disable persisting for the "publish" sidebar as well. The only sidebar that needs to be persisted is the "desktop" sidebar. So maybe instead of a blacklist, we should do a whitelist to fix these two errors together?

@jorgefilipecosta
Copy link
Member Author

Good point @youknowriad. It looks like desktop sidebar is a preference in its own right persisted across sessions. But mobile, and publish sidebars are not preference they are just transient information for the UI state. I'm thinking on discarding this logic for mobile, and create a new reducer called transientSiderbars that contain the mobile and publish sidebars while desktop continues to be a preference. In your option would that be a preferable approach? If yes I will close this PR and create a new one with this changes.

@youknowriad
Copy link
Contributor

@jorgefilipecosta That's a good option, but what about an alternative using a REDUX_SERIALIZE action like suggested by @aduth similar to what we have in Calypso? This action if defined would filter the state and return only the preferences that needs to be saved?

payload.isSidebarOpenedMobile ? { ...payload, isSidebarOpenedMobile: false } : payload
export const disableMobileSidebar = ( payload ) => (
get( payload, 'sidebars.mobile' ) ?
{ ...payload, ...{ sidebars: { ...payload.sidebars, mobile: false } } } :
Copy link
Contributor

@chriskmnds chriskmnds Jan 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies upfront for my incompetence, but is the second spread operator necessary in this case? isn't this the same as { ...payload, sidebars: { ...payload.sidebars, mobile: false } }?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @chriskmnds, you are totally right 👍 your code is equivalent and simpler.

@jorgefilipecosta
Copy link
Member Author

Hi @youknowriad PR #4529 tries a different approach related to your suggestion :) I'm closing this one for now.

@youknowriad youknowriad deleted the fix/disable-mobile-sidebar branch January 17, 2018 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Mobile Web Viewport sizes for mobile and tablet devices [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants