-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Remember last opened side panel in the editor on page load #9269
Remember last opened side panel in the editor on page load #9269
Conversation
Manage this branch in SquashTest this branch here: https://laymonageremember-side-panel-p-tf392.squash.io |
@laymonage would we worth tackling #9216 (comment) while at it. That is, have the info panel open by default (if no previous "last opened side panel" state exists). @thibaudcolas what do you think? |
83d7a03
to
01b525d
Compare
@zerolab Not sure if that would be a good idea as that means the info panel would cover the entire screen on first load on smaller screens. We could add a check to only do this on a certain minimum device screen width, but I personally would rather avoid having such checks in JS. Besides, it's only one click away for users to show the info panel and it stays there on page reload. I get the point that it'd be useful to have it open by default for users who are new to 4.0, though... |
A few thoughts
|
@lb- the idea here is that there isn’t much of a point in not having a side panel opened. Our initial designs for this were to always have the "info" panel opened by default, but as discussed briefly above, it feels better to just keep opened whatever the user had opened last. The idea is definitely that this would stay throughout multiple editing sessions. I think it’d be even more confusing if we did this per page or per session. For that reason as well I don’t think a URL param is the right approach, we want this for all editing that involves side panels. We could use a cookie like we do for the collapsed sidebar, but I don’t think it’s as worthwhile as there is no layout shift involved in displaying a panel. |
@thibaudcolas thanks for explaining - no further push back from me on this. For session storage - we should wrap usage in a try / catch - for a small bit of progressive enhancement if the user has disabled some things in their browser. Good point about the layout shift. Thanks. And thanks @laymonage for working on this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All working great @laymonage. This is missing the error handing for localStorage, but in this instance for all scenarios the error handling is just "proceed" as if nothing was saved – so this feels small enough for me to add now as part of merging.
@@ -43,6 +43,7 @@ function initPreview() { | |||
const deviceWidth = event.target.dataset.deviceWidth; | |||
|
|||
setPreviewWidth(deviceWidth); | |||
localStorage.setItem('wagtail-preview-panel-device', device); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
localStorage.setItem('wagtail-preview-panel-device', device); | |
localStorage.setItem('wagtail:preview-panel-device', device); |
For consistency with e.g. the sprite data.
Also needs to be wrapped in a try
as localStorage
retrieval will crash hard in private browsing.
setPreviewWidth(); | ||
|
||
// Remember last selected device size | ||
const lastDevice = localStorage.getItem('wagtail-preview-panel-device'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const lastDevice = localStorage.getItem('wagtail-preview-panel-device'); | |
const lastDevice = localStorage.getItem('wagtail:preview-panel-device'); |
01b525d
to
de01922
Compare
Please check the following:
make lint
from the Wagtail root.Chrome 105.0.5195.125, Firefox 105.0.1, Safari 16.0
Please describe additional details for testing this change.
Footnotes
Development Testing ↩
Browser and device support ↩
Accessibility Target ↩