sphinx-needs icon indicating copy to clipboard operation
sphinx-needs copied to clipboard

Nested needs and custom layout with collapse_button

Open ubmarco opened this issue 3 years ago • 2 comments

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 image 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: nested_needs_collapse_affect_others

ubmarco avatar Jul 27 '22 14:07 ubmarco

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

ubmarco avatar Jul 27 '22 14:07 ubmarco

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

ubmarco avatar Jul 27 '22 14:07 ubmarco