Skip to content

Fix select controls to handle groups in reactions#1516

Merged
ovidiuch merged 7 commits intoreact-cosmos:mainfrom
max-scopp:feature/grouped-options
Feb 6, 2024
Merged

Fix select controls to handle groups in reactions#1516
ovidiuch merged 7 commits intoreact-cosmos:mainfrom
max-scopp:feature/grouped-options

Conversation

@max-scopp
Copy link
Contributor

See #1513

`options` of `FixtureStateSelectControl` now accepts an array of objects with `group` and `options` in addition to an array of strings. This commit also updates the use of `options` in `useSelect` and `Select` to handle groups, and defines `GroupedOptions` and `isGroupedOptions` in a separate file shared among multiple components. Finally, a new fixture in `Select.fixture.tsx` showcases the new `group`ed options for rendering select controls.
Copy link
Member

@ovidiuch ovidiuch left a comment

Choose a reason for hiding this comment

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

Looks pretty good! A few changes and a useSelect test and we can merge it. If you find creating the test confusing let me know and I can help.

@ovidiuch
Copy link
Member

Just realized this also needs attention:

}, [String(args.options), defaultValue, selectName, setFixtureState]);

Stringifying the options list is a trick make the options list a dependency of that hook without invalidating the effect on every render even if the options list is identical. But stringifying an array of string is the equivalent of array.join(',') and this won't work anymore when the options can contain group objects. So this needs to be changed to JSON.stringify(args.options) or something else.

@ovidiuch
Copy link
Member

ovidiuch commented Dec 2, 2023

@max-scopp are you still interested in getting this merged? I can help if needed :).

@ovidiuch ovidiuch marked this pull request as ready for review February 6, 2024 21:33
@ovidiuch
Copy link
Member

ovidiuch commented Feb 6, 2024

Figured out I had write access on the fork so I made the changes myself 😉

@ovidiuch ovidiuch enabled auto-merge (squash) February 6, 2024 21:42
@ovidiuch ovidiuch merged commit a484ae0 into react-cosmos:main Feb 6, 2024
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