Nested needs and custom layout with collapse_button
The collapse_button setting inital=True does not work correctly with nested needs.
conf.py
needs_layouts = {
"common": {
"grid": "simple",
"layout": {
"head": [
'<<meta("type_name")>> **<<meta("title")>>**'
' <<collapse_button("meta",collapsed="icon:arrow-down-circle",'
' visible="icon:arrow-right-circle", initial=True)>> '
],
"meta": [
'id: <<meta_id()>>',
'<<meta_all(no_links=True, exclude=["layout","style","template"])>>',
"<<meta_links_all()>>",
],
},
},
}
index.rst
.. story:: Test story
:id: ST_lvl1
:status: open
:layout: common
.. story:: Test story
:id: ST_lvl2
:status: open
:layout: common
.. story:: Test story
:id: ST_lvl3
:status: open
:layout: common
.. story:: Test story
:id: ST_lvl4
:status: open
:layout: common
.. story:: Test story
:id: ST_lvl5
:status: open
:layout: common
Output
So every second need is closed an document load. The setting inital=True should, however, affect all nested needs.
Also the collapse button toggling does not work correctly as one click also triggers all nested needs below:

I added a minimum working example showing the problem to a new branch into the doc_basic test data: https://github.com/useblocks/sphinx-needs/tree/mh-nested-needs-collapse-example/tests/doc_test/doc_basic
I guess the issue is somewhere in the jQuery code in https://github.com/useblocks/sphinx-needs/blob/master/sphinx_needs/libs/html/sphinx_needs_collapse.js