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

Section defaultIsOpen does the opposite of the provided boolean #6322

Closed
nerdstep opened this issue Aug 17, 2023 · 0 comments · Fixed by #6326
Closed

Section defaultIsOpen does the opposite of the provided boolean #6322

nerdstep opened this issue Aug 17, 2023 · 0 comments · Fixed by #6326

Comments

@nerdstep
Copy link
Contributor

Environment

  • Package version(s): 5.2.0
  • Operating System: Windows 11
  • Browser name and version: Chrome 115

Code Sandbox

Link to a minimal repro (fork this code sandbox): https://codesandbox.io/p/sandbox/objective-easley-stwn3x

Steps to reproduce

  1. See linked code sandbox.

Actual behavior

The Section component collapseProps.defaultIsOpen does the opposite of what is expected, i.e. when defaultIsOpen={true} the collapse is closed, and when defaultIsOpen={false} the collapse is open.

Expected behavior

When defaultIsOpen={true} the collapse should initially be open.

Possible solution

The component defines an useState variable called isCollapsed which is initialized with the defaultIsOpen value. This value should be negated when initially provided to useState.

const [isCollapsed, setIsCollapsed] = React.useState<boolean>(!collapseProps?.defaultIsOpen ?? false);

https://github.com/palantir/blueprint/blob/develop/packages/core/src/components/section/section.tsx#L112C67-L112C68

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