documentTree collapses when clicking on sub pages

Hello,

I am having a hard time trying to work out how to keep the tree expanded when I click on a sub item.

For example, I have this code I copied from the main Navigation Panel


{{velocity}}
#panelheader($services.localization.render('xe.panels.navigation'))
## Escape special characters in macro parameter values.
#set ($openToDoc = $doc.documentReference.toString().replaceAll('([~"])', '~$1'))
{{documentTree showTranslations="false" showAttachments="false" compact="true" root="document:play:DEMO.WebHome" openTo="document:$openToDoc" /}}
#panelfooter()
{{/velocity}}

With the root directive, this is indicating I have a sub wiki called play and my WebHome lives in DEMO

DEMO
  * Page1
    *SubPage of Page1
  * Page2
    *SubPage of Page2
      *SubSubPage1 of Page2
      *SubSubPage2 of Page2
  *Page3

So, with the above code, I get a list that looks like this (the showRoot directive is not true):

>Page1
>Page2
*Page3

When I expand Page1 or Page2 and click on any subpage (or subsubpage), the expand does not remain, and everything collapses. This makes it very difficult to navigate around the wiki.

However, that being said, on the built-in Navigation Panel, this doesn’t happen. It will happily stay expanded and the “tree” will follow me when navigating through the wiki. I don’t understand why it doesn’t do that when I used the same code elsewhere.

I hope that makes sense. Any help or pointers in the right direction would be greatly appreciated.

Cheers.

Surly I can’t be the only one who has (had?) this problem xD

Could anyone verify if they are having the same issue as I am? Copy/paste the code and change root to match your env, then check to see if the tree collapses when you click on a sub page…

I am using this code inside of the Menu application on the left Panel.

Cheers.

Works for me. You should check if there are any JavaScript errors logged in the browser console (developer tools). You can also check if the tree is expanded when using a fixed value for the openTo parameter. E.g.:

{{documentTree showTranslations="false" showAttachments="false" compact="true" root="document:xwiki:Help.WebHome" openTo="document:xwiki:Help.Applications.Movies.WebHome" /}}

Hi, thanks for the reply.

I failed to mention that I was trying this on the latest stable build, version 10. I have reverted to the LTS 9.11.2 (for production use). I do not have this issue in the LTS version. The code I have posted works like a charm; my tree stays expanded :slight_smile:

Cheers!