# Feature DREAM-309 - [TreeView] Bubble the expanded state from children to parents

Project: Stream Design System
Status: closed
URL: https://community.openproject.org/work_packages/DREAM-309

## Planning

| Attribute | Value |
| --- | --- |
| Date |  |
| Priority | Medium |
| Target versions | 16.1.0 |
| Sprint |  |
| Backlog bucket |  |
| Votes |  |
| List |  |
| Roadmap |  |
| Relevance |  |

## OPEN POINTS / FEEDBACK

_No work packages_

## Use cases

_No work packages_

## Features and Chunks

_No work packages_

## Bugs and other work packages

_No work packages_

## Technical Details

| Attribute | Value |
| --- | --- |
| Module | Frontend components and Primer design system / TreeView |
| Feature Flag |  |
| Requires doc change | No |
| Enterprise plan |  |

## Details

| Attribute | Value |
| --- | --- |
| Pull preview |  |
| Mockups |  |
| Accessibility | No |

## People

| Attribute | Value |
| --- | --- |
| Assignee |  |
| Accountable |  |
| Product manager |  |
| Feature Lead |  |
| Developers | Cameron Dutro |
| Designer | Parimal Satyal |
| Ordered by |  |
| Signed off by |  |
| Interest by |  |

## Estimates and progress

| Attribute | Value |
| --- | --- |
| PD (min) |  |
| PD (max) |  |
| Work |  |
| Labor costs |  |

## Description

The following is a follow up of [this comment](https://community.openproject.org/projects/design-system/work_packages/62993/activity#comment-1189150) of <mention class="mention" data-id="62993" data-type="work_package" data-text="#62993">#62993</mention>

## Problem

> Imagine the following very simple TreeView:
> 
> ``` erb
>   <%= render(Primer::OpenProject::TreeView.new) do |tree_view| %>
>     <% tree_view.with_sub_tree(label: "src") do |sub_tree| %>
>       <% sub_tree.with_leaf(label: "button.rb", select_variant: select_variant) %>
>       <% sub_tree.with_leaf(label: "icon_button.rb") %>
> 
>       <% sub_tree.with_sub_tree(label: "sub-folder", expanded: true, select_variant: select_variant, select_strategy: select_strategy) do |sub_tree2| %>
>         <% sub_tree2.with_leaf(label: "test.rb") %>
>         <% sub_tree2.with_leaf(label: "blankslate.rb", current: true) %>
>       <% end %>
>     <% end %>
> 
>     <% tree_view.with_leaf(label: "action_menu.rb") %>
>   <% end %>
> ```
> 
> Please note, that the second sub\_tree has `expanded: true` while the surrounding sub\_tree has `expanded` not set. Now, this will render to:
> 
> <img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/567537/content">

> So, I will not see the subtree that I wanted to be expanded, because the parent is not expanded. I (as a developer) would have to manage that manually by setting each parent tree to `expanded: true`.

# Solution

**As** a developer  
**I want to** set the `expanded` attributes only once  
**so that** I do not have to repeat that for every node in the hierachy

**Acceptance criteria**

  - Whenever, I set the value `expanded: true` on a leave or a node, all of its parent are automatically set to `expanded: true` as well.

**Hint for QA**

  - Can be tested here: <https://qa.openproject-edge.com/lookbook/inspect/primer/open_project/tree_view/auto_expansion>
