XUL tree twisty state won't persist if XML template is used




6 years ago
6 years ago


(Reporter: Hovhannes Babayan, Assigned: Neil Deakin (mostly unavailable until September))



Windows 7
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)



(3 attachments)



6 years ago
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

6 years ago
Created attachment 538782 [details]
XUL file with tree template

Comment 2

6 years ago
Created attachment 538784 [details]
Sample XML datasource file
Attachment #538782 - Attachment mime type: application/octet-stream → application/vnd.mozilla.xul+xml
Attachment #538784 - Attachment mime type: application/octet-stream → text/xml
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
Assignee: nobody → enndeakin
Ever confirmed: true
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.
Attachment #538968 - Flags: review?(jonas)
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?
Attachment #538968 - Flags: review?(jonas) → review+
Keywords: dev-doc-needed
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.
Sure, but we still need to document this somewhere other than
In this bug.
My comment 6 is intended to be a summary to be used by someone documenting this.
Last Resolved: 6 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
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.
Probably at https://developer.mozilla.org/en/XUL/Template_Guide/XML_Templates or https://developer.mozilla.org/en/XUL/Template_Guide/Building_Trees
Added notes:


And mentioned on Firefox 7 for developers.
Keywords: dev-doc-needed → dev-doc-complete

Comment 13

6 years ago
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
You need to log in before you can comment on or make changes to this bug.