Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to have panel collapsed on load #41

Open
mhkeller opened this issue Aug 18, 2024 · 1 comment
Open

Add option to have panel collapsed on load #41

mhkeller opened this issue Aug 18, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@mhkeller
Copy link

mhkeller commented Aug 18, 2024

Describe the feature in detail (code, mocks, or screenshots encouraged)

Currently, you can set a defaultSize to determine the height on load, but you can't default to having a panel be collapsed on load. I wanted to set the defaultSize for when the panel is in its expanded state but have the panel start off on load. I couldn't find any current way to do this with props.

Here's what I ended up doing to solve it:

function togglePane() {
  if (myPane.isCollapsed()) {
    myPane.expand();

    // We can't set a default size of 50 and also have it be collapsed on load
    // so the first time we expand it, we set it to 50
    const currentSize = myPane.getSize();
    if (currentSize === 0) {
      myPane.resize(50);
    }
    
  } else {
    myPane.collapse();
  }
}

It would be helpful if there were a collapse prop on the component so I could do something like this instead:

<Pane defaultSize={50} minSize={0} collapsed={myPaneIsCollapsed} />

What type of pull request would this be?

New feature

@mhkeller mhkeller added the enhancement New feature or request label Aug 18, 2024
@huntabyte
Copy link
Member

Couldn't this be accomplished like this?

<Pane defaultSize={myPaneIsCollapsed ? 0 : 50} minSize={0} />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants