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

fix(www): ensure that there is a value when changing the panel size #3641

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ItsValerius
Copy link

This PR fixes the issue described here:
#3640

Copy link

vercel bot commented May 1, 2024

@ItsValerius is attempting to deploy a commit to the shadcn-pro Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

@flixlix flixlix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest the following changes:

const [currentSize, setCurrentSize] = React.useState("100")
value={currentSize}
onValueChange={(value) => {
  if (resizablePanelRef.current && value) {
    setCurrentSize(value)
    resizablePanelRef.current.resize(parseInt(value))
  }
}}

this way, when clicking a size that was already selected, we can make sure that it doesn't get deselected. By making the toggle group controlled we make sure at least one is always selected

@ItsValerius
Copy link
Author

I would suggest the following changes:

const [currentSize, setCurrentSize] = React.useState("100")
value={currentSize}
onValueChange={(value) => {
  if (resizablePanelRef.current && value) {
    setCurrentSize(value)
    resizablePanelRef.current.resize(parseInt(value))
  }
}}

this way, when clicking a size that was already selected, we can make sure that it doesn't get deselected. By making the toggle group controlled we make sure at least one is always selected

Good idea!
I made some changes to your suggestions to make sure the buttons would still work, if the ResizablePanel was changed by dragging it around.

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

Successfully merging this pull request may close these issues.

None yet

2 participants