Skip to content

Add "default closed groups" prop#10

Merged
birkir merged 1 commit intobirkir:masterfrom
cdriesler:default-closed-groups
Aug 19, 2020
Merged

Add "default closed groups" prop#10
birkir merged 1 commit intobirkir:masterfrom
cdriesler:default-closed-groups

Conversation

@cdriesler
Copy link
Copy Markdown
Contributor

Adds an optional defaultClosedGroups string array prop to the root <Control /> element. When set, any groups named in the array will show as closed on first draw.

Example

const a = useControl('First Setting', { type: 'boolean'})
const b = useControl('Second Setting', { type: 'boolean', group: 'GroupA' })
const c = useControl('Third Setting', { type: 'boolean', group: 'GroupB' })

return <Control defaultClosedGroups={['GroupB']} />

Settings list GroupB would then be collapsed on first draw.

Note

Using this library a lot lately (thank you!) and could really use the option for some of my longer control lists. Understood if this is not ideal because it's a rogue prop on the top-level component. Betting that this is preferred to polluting the useControl hook, but happy to do a version with it there instead if I was wrong.

@birkir birkir merged commit 1900447 into birkir:master Aug 19, 2020
@birkir
Copy link
Copy Markdown
Owner

birkir commented Aug 19, 2020

Sorry for the late merge. Thank you!

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.

2 participants