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 select controls to handle groups in reactions #1516

Merged
merged 7 commits into from
Feb 6, 2024

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
12 checks passed
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