Last Comment Bug 663728 - XUL tree twisty state won't persist if XML template is used
: XUL tree twisty state won't persist if XML template is used
: dev-doc-complete
Product: Core
Classification: Components
Component: XUL (show other bugs)
: unspecified
: x86_64 Windows 7
-- normal (vote)
: ---
Assigned To: Neil Deakin
: Neil Deakin
Depends on:
  Show dependency treegraph
Reported: 2011-06-12 14:14 PDT by Hovhannes Babayan
Modified: 2011-11-02 06:53 PDT (History)
2 users (show)
enndeakin: in‑testsuite+
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

XUL file with tree template (581 bytes, application/vnd.mozilla.xul+xml)
2011-06-12 14:28 PDT, Hovhannes Babayan
no flags Details
Sample XML datasource file (262 bytes, text/xml)
2011-06-12 14:29 PDT, Hovhannes Babayan
no flags Details
fix (15.04 KB, patch)
2011-06-13 11:45 PDT, Neil Deakin
jonas: review+
Details | Diff | Splinter Review

Description User image Hovhannes Babayan 2011-06-12 14:14:59 PDT
User-Agent:       Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11
Build Identifier: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1

I've an XUL tree element with querytype="xml" attribute set. Tree element is populated from XML datasource. Datasource has the following format:
   <item name="A" id="1">
      <item name="A child 1" id="2"/>
      <item name="A child 1" id="3"/>
   <item name="B" id="4">
   <item name="C" id="5">
      <item name="C child 1" id="6"/>

The bug is that tree twisty state won't persist. For example, if I open items A and C using twisty button, they won't stay open after window reload.

For comparison. If RDF datasource is used and "rdf:about"
attribute is present on items A and C, tree remembers twisty state
correctly, that is, if I open children of item A and then reload my
XUL window, item A remains opened.

Reproducible: Always

Steps to Reproduce:
1. Prepare XML datasource with nested levels, with "id" attributes for each item
2. Prepare XUL tree with template, which will generate nested treeitems if recursive datasource is attached
3. Attach XML datasource from step 1 to tree from step 2. Make sure, that tree has nested treeitems, which can be opened/closed using twisty button.
4. Open any treeitem to see its children
5. Reload window

Actual Results:  
Opened treeitem appears closed after reloading window.

Expected Results:  
Opened treeitem should stay opened after reloading window if "id" attribute is present in XML datasource

Such behavior was observed under both 32 and 64 bit Windows for all Firefox/XULRunner versions with XML datasource support.
Comment 1 User image Hovhannes Babayan 2011-06-12 14:28:15 PDT
Created attachment 538782 [details]
XUL file with tree template
Comment 2 User image Hovhannes Babayan 2011-06-12 14:29:03 PDT
Created attachment 538784 [details]
Sample XML datasource file
Comment 3 User image Neil Deakin 2011-06-13 11:45:47 PDT
Created attachment 538968 [details] [diff] [review]

This patch fixes this issue.

Two comments about the testcase that would need to be changed:
- an xml id needs to be declared in the xml source
- the patch only works for dont-build-content trees
Comment 4 User image Neil Deakin 2011-06-17 14:36:41 PDT
Comment on attachment 538968 [details] [diff] [review]

This patch generates the id from the source node's id, rather than using a random value. This way it is always the same each time so persistence can work.
Comment 5 User image Jonas Sicking (:sicking) No longer reading bugmail consistently 2011-06-21 23:47:45 PDT
Comment on attachment 538968 [details] [diff] [review]

Is it documented somewhere how this stuff works? And that we're recommending that you put an id on the relevant elements?
Comment 6 User image Neil Deakin 2011-06-23 06:57:24 PDT
The idea is that the datasource nodes should have ids if you plan to you the persist feature with them. Persisting of open tree nodes is part of the tree builder, so ids are needed there. However, if you don't want or need persistence, then ids aren't necessary.
Comment 7 User image Jonas Sicking (:sicking) No longer reading bugmail consistently 2011-06-23 11:30:34 PDT
Sure, but we still need to document this somewhere other than
In this bug.
Comment 8 User image Neil Deakin 2011-06-23 11:34:01 PDT
My comment 6 is intended to be a summary to be used by someone documenting this.
Comment 10 User image Eric Shepherd [:sheppy] 2011-08-05 13:20:13 PDT
Looking for suggestions on appropriate places to document this. Would this be one?

Any other suggestions? This isn't an area of the docs I've done much with, so I want to be sure to get it right.
Comment 13 User image Hovhannes Babayan 2011-11-02 06:53:22 PDT
I've added flags="dont-build-content" to XUL tree in the example bug.xul attached above, but treeitem state still doesn't persist.
I am using Firefox 7

Note You need to log in before you can comment on or make changes to this bug.