Problem/Motivation
The new issues fieldsets on the node view don't keep persistent states when opened/closed (when things like AJAX replace the entire form due to the project field losing focus).
Proposed resolution
Keep the fieldset states persistent using localStorage.
Save the focused element when the AJAX form has been replaced.
Example of changes can be seen on:
http://form-drupal.redesign.devdrupal.org/node/2130811 (dev)
Without the changes:
http://page-drupal.redesign.devdrupal.org/node/2130811 (stage)
htaccess: drupal/drupal
login: bacon/bacon
Steps to reproduce
(go to dev site example issue links, log in, log in)
- open files fieldset
- open issue summary fieldset (and edit something)
- open meta data fieldset (change issue from bug to task or something)
- click into the project field
- tab out
- wait
before fix: page reloads with the fieldsets closed. annoying.
after fix: page reloads and the fieldsets are as I left them. much better.
Remaining tasks
None
User interface changes
Open/closed fieldsets will be persistent with page refreshes and AJAX replacements.
API changes
Original report by Mark Carver
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 2163197-8.patch | 4 KB | markhalliwell |
| #8 | interdiff.txt | 2.29 KB | markhalliwell |
Comments
Comment #1
markhalliwellComment #2
markhalliwellIssue #2163197 by Mark Carver: Allow fieldsets to be persistent and save focus when AJAXing.
Committed to master and stage:
https://github.com/dreditor/drupal_org/commit/306579bb2804e70d842e8ed85b...
Example of changes can be seen on both sites:
http://form-drupal.redesign.devdrupal.org/node/2130811 (dev)
http://page-drupal.redesign.devdrupal.org/node/2130811 (stage)
Comment #3
drummThis looks like some great JS code, but I'm not sure what the goal is without digging.
The "Issue node view fields." comment should be expanded to briefly explain what is being done to them.
The issue summary could use some steps to reproduce, so we know where to look.
Comment #4
markhalliwellI've rolled back staging to before the patch, so you can see a "before" and "after".
Basically, if you refresh the page or purposefully/accidentally focus or change the project field the entire form is replaced, thus collapsing the fieldset again. It also loses where the focus is (ie: if you tab from the project field, you go to the version version, but it's no longer focused when it's replaced via AJAX).
This patch fixes all that and keeps persistent fieldset collapsed states (leveraging the browser's localStorage) and persistent input focus (on AJAX replacements).
Comment #5
markhalliwellI'll update the patch to be a little more descriptive.
Comment #6
markhalliwellMoving to project_issue after discussing this with @drumm. This is generic code that can be used by all, not drupalorg specific.
Comment #7
markhalliwellOk, here's a new patch against the project_issue module instead. Interdiff is useless.
Comment #8
markhalliwellChanged some of the namespacing to be consistent.
Comment #9
markhalliwellExample of changes can be seen on:
http://form-drupal.redesign.devdrupal.org/node/2130811 (dev)
Without the changes:
http://page-drupal.redesign.devdrupal.org/node/2130811 (stage)
htaccess: drupal/drupal
login: bacon/bacon
Comment #10
markhalliwellComment #11
yesct commentedI tried it on the before site (page)
And on the after site (form)
Much better with this fix.
Did not do a code review.
===
added steps to reproduce to issue summary
Comment #12
webchickThis actually sounds like a neat potential future addition to field_group module as a user-configurable setting on a per-field group basis. (NOT as a blocker for this deployment. :P~)
I mention this because while I love this feature for both issue metadata + files, it always makes me fall out of my chair when the issue summary & relations one gets expanded by default because the last issue I edited 8 hours ago happened to have one of those changes in it.
I don't think this is a huge deal though. Most people who routinely edit issue summaries probably like the fact that it stays open.
Comment #13
markhalliwellYes, I think this should be fixed upstream (while putting this in for now, until we can). Honestly though, I think this should really should just be part of core period as part of the FAPI (like https://drupal.org/sandbox/arshad/1202674 does), it's relatively small code. The reason I didn't use that sandbox was mostly for time. I would have to rewrite a lot of it to not use DB variables. Using the DB for storage seems a completely unnecessary waste and ultimately a high cost considering issues are probably the most active part of d.o. It could also be somewhat unpleasant if we had to do AJAX calls each time the state was retrieved or saved, not really my cup-o'-tea.
The thing I really liked about it though is the
#persistentvalue, I could incorporate something similar and ad adata-collapsible="true"to thefieldsettag:Then we could specifically target only the fieldsets we want (ie: metadata, files).
Another thing I ran into is that, technically, the form is same for both the view and edit aspects of the node. If one expands or collapses the fieldset say on the node view the same will be applied if they go to the node edit. I think maybe we should add a new key value:
#persistent_prefixwhich, by default, would use theform_id. This way we couldamend theuseform_idwith_embededfor'#persistent_prefix' => $form['#form_id'] . '_embeded'for the node view.Thoughts?
Comment #14
yesct commented@Mark Carver can you open that upstream issue and link it here? I'm not sure what queue it would go in.
Maybe we could put in a @todo, to remove the special code, in this code that links to that new issue.
Comment #15
drummCommitted & deploying.