The default bug view has changed. See this FAQ.

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

RESOLVED FIXED

Status

()

Core
XUL
RESOLVED FIXED
6 years ago
6 years ago

People

(Reporter: Hovhannes Babayan, Assigned: Neil Deakin)

Tracking

({dev-doc-complete})

unspecified
x86_64
Windows 7
dev-doc-complete
Points:
---
Bug Flags:
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments)

(Reporter)

Description

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:
<items>
   <item name="A" id="1">
      <item name="A child 1" id="2"/>
      <item name="A child 1" id="3"/>
   </item>
   <item name="B" id="4">
   <item name="C" id="5">
      <item name="C child 1" id="6"/>
   </item>
</items>

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.
(Reporter)

Comment 1

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

Comment 2

6 years ago
Created attachment 538784 [details]
Sample XML datasource file
(Assignee)

Updated

6 years ago
Attachment #538782 - Attachment mime type: application/octet-stream → application/vnd.mozilla.xul+xml
(Assignee)

Updated

6 years ago
Attachment #538784 - Attachment mime type: application/octet-stream → text/xml
(Assignee)

Comment 3

6 years ago
Created attachment 538968 [details] [diff] [review]
fix

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
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
(Assignee)

Comment 4

6 years ago
Comment on attachment 538968 [details] [diff] [review]
fix

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]
fix

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
(Assignee)

Comment 6

6 years ago
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.
(Assignee)

Comment 8

6 years ago
My comment 6 is intended to be a summary to be used by someone documenting this.
(Assignee)

Comment 9

6 years ago
http://hg.mozilla.org/mozilla-central/rev/e3a9974fdc28
Status: ASSIGNED → RESOLVED
Last Resolved: 6 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Looking for suggestions on appropriate places to document this. Would this be one?

https://developer.mozilla.org/en/XUL/treeitem

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.
(Assignee)

Comment 11

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

https://developer.mozilla.org/en/XUL/Template_Guide/Building_Trees#Using_Tree_Properties
https://developer.mozilla.org/en/XUL/Template_Guide/XML_Templates

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

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.