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

[Select] When there's no value or defaultValue, align with first non-disabled item #1379

Merged
merged 10 commits into from
May 10, 2022

Conversation

benoitgrelard
Copy link
Contributor

@benoitgrelard benoitgrelard commented May 9, 2022

Fixes #1324

I've managed to do even slightly better than we had tested. It will now align not with the first item, but the first non-disabled item. This gives a better experience if some of the first items are disabled.

I've added a chromatic story for it too.

Note: Best to review individual commits

@benoitgrelard benoitgrelard requested a review from andy-hook as a code owner May 9, 2022 15:05
packages/react/select/src/Select.stories.tsx Outdated Show resolved Hide resolved
packages/react/select/src/Select.stories.tsx Outdated Show resolved Hide resolved
packages/react/select/src/Select.stories.tsx Show resolved Hide resolved
packages/react/select/src/Select.tsx Outdated Show resolved Hide resolved
packages/react/select/src/Select.tsx Show resolved Hide resolved
packages/react/select/src/Select.tsx Show resolved Hide resolved
packages/react/select/src/Select.tsx Outdated Show resolved Hide resolved
packages/react/select/src/Select.tsx Outdated Show resolved Hide resolved
packages/react/select/src/Select.tsx Outdated Show resolved Hide resolved
packages/react/select/src/Select.tsx Outdated Show resolved Hide resolved
@MatheusPires99
Copy link

Hey @benoitgrelard , this issues is still happening on the CodeSandbox link example of the Select component.

https://codesandbox.io/s/5exdpd?module=App.js

If you remove the defaultValue the alignment is off.

@benoitgrelard
Copy link
Contributor Author

Hey @MatheusPires99, it's available in latest release candidates. V1 is going out imminently (should be tomorrow).

@MatheusPires99
Copy link

Oh nice to hear that. I will wait to check the v1 then. Thanks a lot @benoitgrelard

luisorbaiceta pushed a commit to luisorbaiceta/primitives that referenced this pull request Jul 21, 2022
…non-disabled item (radix-ui#1379)

* Do not lie about content context type

* Add story for alignment without default value

* Align with first valid item when no value is set

* Versions

* Update Select.stories.tsx

* Apply suggestions from code review

Co-authored-by: Andy Hook <hello@andy-hook.co.uk>

* firstItemRef -> firstValidItemFoundRef

* PR feedback

* Rename ref callbacks

* PR feedback

Co-authored-by: Andy Hook <hello@andy-hook.co.uk>
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.

[Select] Select content is misaligned when defaultValue or value is not passed
3 participants