-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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): pass portalContainer to the pop-over #3698
base: canary
Are you sure you want to change the base?
fix(select): pass portalContainer to the pop-over #3698
Conversation
🦋 Changeset detectedLatest commit: ae0f5fa The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@macci001 is attempting to deploy a commit to the NextUI Inc Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughThis update enhances the select component by introducing a Changes
Assessment against linked issues
Possibly related PRs
Recent review detailsConfiguration used: .coderabbit.yaml Files selected for processing (5)
Files skipped from review due to trivial changes (1)
Files skipped from review as they are similar to previous changes (3)
Additional context usedLanguageTool
Additional comments not posted (10)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (2)
- .changeset/clean-eagles-clean.md (1 hunks)
- packages/components/select/src/use-select.ts (5 hunks)
Additional comments not posted (2)
packages/components/select/src/use-select.ts (2)
235-235
: LGTM! The addition ofbaseRef
enhances the component's functionality.The new
baseRef
reference is correctly initialized, passed togetBaseProps
, and included in the dependency array. This allows the base element to be managed using the reference and ensures that any changes tobaseRef
will trigger a re-computation of the base element props.Also applies to: 384-384, 396-396
524-524
: LGTM! PassingbaseRef
togetPopoverProps
improves the popover functionality.Assigning
baseRef.current
to theportalContainer
prop allows the popover to be rendered in relation to the base element. IncludingbaseRef
in the dependency array ensures that any changes tobaseRef
will trigger a re-computation of the popover props.Also applies to: 547-547
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- please add test
- please share the code you showed in PR description
hi @wingkwong
I think the fix to add the portalContainer, the UI with multiple selects misbehaves(when select1 is open, the click on select2 closes the select1 but does not open the select2 until one more click on it.) |
29de544
to
a2a5468
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Outside diff range, codebase verification and nitpick comments (1)
packages/components/select/src/use-select.ts (1)
Line range hint
383-395
: Review thegetBaseProps
function for potential improvements.The
getBaseProps
function is correctly using thebaseRef
to set theref
property. However, consider using a more descriptive name for thedata-slot
attribute to enhance readability and maintainability.- "data-slot": "base", + "data-slot": "select-base",
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (3)
- .changeset/clean-eagles-clean.md (1 hunks)
- packages/components/select/tests/select.test.tsx (2 hunks)
- packages/components/select/src/use-select.ts (5 hunks)
Additional comments not posted (3)
packages/components/select/src/use-select.ts (2)
234-234
: Addition ofbaseRef
is well-implemented.The introduction of
baseRef
usinguseRef
is correctly implemented and follows React best practices for managing references.
Line range hint
523-543
: Ensure correct implementation ofportalContainer
prop.The
getPopoverProps
function now correctly usesbaseRef.current
to dynamically set theportalContainer
. This is a crucial fix that aligns with the PR's objectives to handle the pop-over behavior correctly. Ensure thorough testing to verify that this change behaves as expected across all use cases.Run the following script to verify the correct implementation of
portalContainer
:Verification successful
Verification Successful: Correct Implementation of
portalContainer
PropThe
portalContainer
prop in thegetPopoverProps
function is correctly implemented usingbaseRef.current ?? undefined
, as expected. This aligns with the review comment's approval and ensures the desired behavior for the pop-over functionality.
- Location:
packages/components/select/src/use-select.ts
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the correct implementation of `portalContainer` in `getPopoverProps`. # Test: Search for the usage of `portalContainer`. Expect: Only occurrences with `baseRef.current`. rg --type typescript -A 5 $'portalContainer: baseRef.current'Length of output: 97
Script:
#!/bin/bash # Description: Verify the correct implementation of `portalContainer` in `getPopoverProps`. # Test: Search for the usage of `portalContainer`. Expect: Only occurrences with `baseRef.current`. rg --type ts -A 5 $'portalContainer: baseRef.current'Length of output: 538
packages/components/select/__tests__/select.test.tsx (1)
656-695
: New test case is well-implemented and relevant.The test case "should not close when parent is scrollable" is well-implemented and directly addresses the issue described in the PR. It effectively tests the
Select
component's behavior in a scrollable environment, ensuring that the pop-over remains open as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (1)
- .changeset/clean-eagles-clean.md (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- .changeset/clean-eagles-clean.md
Update:
// cc @wingkwong |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pr3698-issue.webm
3a3cd11
to
bf7fe71
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Outside diff range and nitpick comments (3)
apps/docs/content/docs/components/select.mdx (3)
122-122
: Consider adding a comma after "By default".According to the static analysis hint, adding a comma after "By default" would improve the sentence structure.
-By default the select uses a `chevron-down` icon as the selector icon which rotates when the select is open. +By default, the select uses a `chevron-down` icon as the selector icon which rotates when the select is open.Tools
LanguageTool
[uncategorized] ~122-~122: Did you mean: “By default,”?
Context: ...t="350px" /> ### Custom Selector Icon By default the select uses achevron-down
icon a...(BY_DEFAULT_COMMA)
176-176
: Consider adding a comma after "By default".According to the static analysis hint, adding a comma after "By default" would improve the sentence structure.
-By default the select will render the selected item's text value, but you can customize this by passing a `renderValue` function. +By default, the select will render the selected item's text value, but you can customize this by passing a `renderValue` function.Tools
LanguageTool
[uncategorized] ~176-~176: Did you mean: “By default,”?
Context: ...ht="350px" /> ### Custom Render Value By default the select will render the selected ite...(BY_DEFAULT_COMMA)
250-250
: Consider adding a comma to improve the sentence structure.According to the static analysis hint, adding a comma would improve the sentence structure.
-You can render any component as the select value by using the `renderValue` property. In this example we are +You can render any component as the select value by using the `renderValue` property. In this example, we are using the [Chip](/docs/components/chip) component to render the selected items.Tools
LanguageTool
[typographical] ~250-~250: It appears that a comma is missing.
Context: ...ing therenderValue
property. In this example we are using the [Chip](/docs/component...(DURING_THAT_TIME_COMMA)
Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Files selected for processing (2)
- apps/docs/content/components/select/open-state.ts (1 hunks)
- apps/docs/content/docs/components/select.mdx (9 hunks)
Files skipped from review due to trivial changes (1)
- apps/docs/content/components/select/open-state.ts
Additional context used
LanguageTool
apps/docs/content/docs/components/select.mdx
[uncategorized] ~122-~122: Did you mean: “By default,”?
Context: ...t="350px" /> ### Custom Selector Icon By default the select uses achevron-down
icon a...(BY_DEFAULT_COMMA)
[uncategorized] ~176-~176: Did you mean: “By default,”?
Context: ...ht="350px" /> ### Custom Render Value By default the select will render the selected ite...(BY_DEFAULT_COMMA)
[typographical] ~250-~250: It appears that a comma is missing.
Context: ...ing therenderValue
property. In this example we are using the [Chip](/docs/component...(DURING_THAT_TIME_COMMA)
Additional comments not posted (14)
apps/docs/content/docs/components/select.mdx (14)
48-48
: LGTM!Setting a fixed
previewHeight
ensures consistent presentation across examples.
57-57
: LGTM!Setting a fixed
previewHeight
ensures consistent presentation across examples.
63-63
: LGTM!Setting a fixed
previewHeight
ensures consistent presentation across examples.
73-73
: LGTM!Setting a fixed
previewHeight
ensures consistent presentation across examples.
80-80
: LGTM!Setting a fixed
previewHeight
ensures consistent presentation across examples.
84-84
: LGTM!Setting a fixed
previewHeight
ensures consistent presentation across examples. The different height for this example might be intentional to accommodate its specific content.
88-88
: LGTM!Setting a fixed
previewHeight
ensures consistent presentation across examples. The different height for this example might be intentional to accommodate its specific content.
92-92
: LGTM!Setting a fixed
previewHeight
ensures consistent presentation across examples. The consistent height with the previous example might be intentional to maintain visual coherence between related examples.
96-96
: LGTM!Setting a fixed
previewHeight
ensures consistent presentation across examples. The different height for this example might be intentional to accommodate its specific content.
102-102
: LGTM!Setting a fixed
previewHeight
ensures consistent presentation across examples. The consistent height with the previous example might be intentional to maintain visual coherence between related examples.
111-111
: LGTM!Setting a fixed
previewHeight
ensures consistent presentation across examples. The height is consistent with earlier examples and might be intentional to accommodate the content of this specific example.
119-119
: LGTM!Setting a fixed
previewHeight
ensures consistent presentation across examples. The consistent height with the previous example might be intentional to maintain visual coherence between related examples.
126-126
: LGTM!Setting a fixed
previewHeight
ensures consistent presentation across examples. The consistent height with the previous examples might be intentional to maintain visual coherence between related examples.
135-135
: LGTM!Setting a fixed
previewHeight
ensures consistent presentation across examples. The consistent height with the previous examples might be intentional to maintain visual coherence between related examples.
bf7fe71
to
ae0f5fa
Compare
Hi @wingkwong, Edit: Screen.Recording.2024-09-16.at.12.18.00.PM.mov |
Marked as on hold first. I think setting previewHeight is not correct. It shouldn't behave this way. |
Closes #3695
Closes #3571
📝 Description
⛳️ Current behavior (updates)
Screen.Recording.2024-09-01.at.1.07.52.PM.mov
base
slot ofselect
🚀 New behavior
Screen.Recording.2024-09-01.at.1.01.49.PM.mov
base
slot ofselect
💣 Is this a breaking change (Yes/No): No
Summary by CodeRabbit
Summary by CodeRabbit
New Features
portalContainer
prop for the select component's pop-over, improving usability within scrollable parent components.previewHeight
property to enhance visual consistency in documentation examples.Bug Fixes
items-center
class from the select component's wrapper to adjust layout styling.Tests
These changes collectively enhance the user experience by ensuring the pop-over remains accessible and functional.