[FR] Use sessionStorage to keep track of the selected site in element indexes #8920
-
DescriptionCurrently, Craft saves the selected site ID (in the CP) to a cookie, and the selected site is kept in sync across different element indexes. This works well, except for one detail: In my experience, it is usually authors' expectation that the selected site is kept in sync and maintained on a per browser tab/window basis, which isn't the case at the moment. Currently, if the author opens up a new browser tab/window and changes the selected site in that tab (perhaps to compare content across different sites, to copy/paste content between them etc) the selected site will also change in all other open tabs, as soon as those tabs are reloaded. From the authors perspective, it's easy to miss that this happens, which might result in them editing content in the wrong site without realising. It's also annoying, because it makes attempting to navigate content in different sites at the same time very difficult (authors basically have to use different browsers or incognito windows to pull it off). Since window.sessionStorage is sandboxed to each tab/window, one idea to solve this could be to save the selected site ID to |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
We‘re storing the selected site in an actual cookie as of Craft 3.5 as well, which is the only way we can currently get the Globals section to respect it. Wonder if it would lead to further confusion if that behaved differently than element indexes. We’ll likely be making some changes in Craft 4 that will solve that though, so I’ll put this on the 4.0 milestone. |
Beta Was this translation helpful? Give feedback.
-
Yeah, to be clear I actually meant to include Globals in my references to "element indexes" above :) Also to be clear, I think the current behaviour (where the selected site is kept in sync between globals and entry indexes) is great – it'd just be an improvement (in my opinion) if it was possible to keep it in sync on a per browser tab basis, because I believe that's how most authors would expect it to work. |
Beta Was this translation helpful? Give feedback.
-
Agree, it’s a good idea. |
Beta Was this translation helpful? Give feedback.
-
Any chance this is still on the radar for Craft 4? :) |
Beta Was this translation helpful? Give feedback.
-
This is now implemented for Craft 4 (bcb72b7). The selected site is tracked via a |
Beta Was this translation helpful? Give feedback.
This is now implemented for Craft 4 (bcb72b7). The selected site is tracked via a
site
query string param, which is now included in all generated control panel links on multi-site installs. Decided that would be better thansessionStorage
becausesessionStorage
isn’t sharable, and doesn’t get sent to the server.