Similar to how the shortcut drawer remained open or closed according to the user's last state change operation, we want the toolbar tray to remain open or closed across page loads.

So, if a user opens the menu, navigates to Structure > Blocks and clicks on Blocks. Then when the blocks page loads, the toolbar should be opened to the menu tab, with the Blocks menu item open.

toolbar-open-to-blocks-page.png

Related to #1827302: Preserve the orientation state of the toolbar for individual users across page loads.

CommentFileSizeAuthor
toolbar-open-to-blocks-page.png59.14 KBjessebeach
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jessebeach’s picture

Have a look at the patch nod_ proposed for the shortcut module drawer state: #1772724: Remove most of toolbar things and put that in shortcut

jessebeach’s picture

benjifisher’s picture

Status: Closed (duplicate) » Active

I think the right way to do this is to have an AJAX callback every time a Toolbar tray is opened or closed. Consider this use case:

  1. I open one of the trays, say the Shortcut tray.
  2. I right-click some link on the page and open another page in a new browser window or tab.

I expect the Shortcut tray to be open in my new browser window. I can make this happen if the site gets an AJAX request when the Shortcut tray is opened.

I suppose you can also make it happen by saving a cookie with the Toolbar state. If you do it this way, can you reliably avoid having the page visibly redraw itself?

If we go with my suggestion of AJAX calls, then I can do the PHP side, defining a callback for toolbar/ajax/state or something. I am sure there are plenty of people who will have less trouble than I would with the JS side.

Question: If we do it this way, how should we store the state of the toolbar? We could use a custom table, or we could use the $_SESSION variable. If we use $_SESSION, then

  1. Drupal and PHP handle clearing out old session data. Bug or feature?
  2. I can keep the Shortcut tray open in Firefox and the User tray open in Chrome if I want.

All the same comments apply to #1827302: Preserve the orientation state of the toolbar for individual users across page loads.

benjifisher’s picture

Status: Active » Closed (duplicate)

oops, cross post.

jessebeach’s picture

The way I approached this in #1137920-220: Fix toolbar on small screen sizes and redesign toolbar for desktop and the same way that tableDrag.js addresses this issue is with localStorage. It's a client-side storage mechanism that has the advantages of being super-easy to implement. Sure, it's volatile state that can't be transferred from browser to browser. I would argue that preserving the state of the open toolbar or the orientation of a tray is not mission-critical -- it can be reset very easily. Plus, localStorage won't bust cache like a $_SESSION variable will. We avoid a lot of complexity with a server side solution by trading off stability of state maintenance. In this case that seems like a fair trade. What do you think?

jessebeach’s picture

Issue summary: View changes

added a link to #1827302