-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
feat: add tab ref #3974
feat: add tab ref #3974
Conversation
🦋 Changeset detectedLatest commit: cd67ce2 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 |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe changes in this pull request enhance the documentation and functionality of the Tabs component. Key updates include the addition of a Changes
Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
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: 1
🧹 Outside diff range and nitpick comments (2)
packages/components/tabs/src/tab.tsx (1)
98-98
: Consider adding null check for tabRefWhile the implementation is correct, consider adding a null check before merging refs to prevent potential issues with undefined tabRef.
Here's a safer implementation:
- ref={mergeRefs(domRef, tabRef)} + ref={tabRef ? mergeRefs(domRef, tabRef) : domRef}apps/docs/content/docs/components/tabs.mdx (1)
279-279
: Enhance the tabRef prop documentation with usage examples.While the
tabRef
prop documentation is clear, it would be more helpful to include a brief example of its usage, particularly for cases where direct DOM access is needed (e.g., focus management, scroll into view, etc.).Consider adding a usage example in the description, such as:
"A ref to the tab item. Useful for programmatic focus management or custom DOM interactions. Example:const tabRef = useRef(null);
"
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (4)
apps/docs/content/docs/components/tabs.mdx
(1 hunks)packages/components/tabs/__tests__/tabs.test.tsx
(1 hunks)packages/components/tabs/src/base/tab-item-base.ts
(2 hunks)packages/components/tabs/src/tab.tsx
(3 hunks)
🔇 Additional comments (6)
packages/components/tabs/src/base/tab-item-base.ts (2)
2-2
: LGTM: Clean import addition
The addition of RefObject
import is clean and necessary for the new tabRef
prop type definition.
21-22
: LGTM: Well-documented ref forwarding support
The tabRef
property is well-typed and properly documented. This addition enables proper ref forwarding, which is a common React pattern for accessing DOM elements directly when necessary.
Let's verify the test coverage for this new prop:
✅ Verification successful
Proper test coverage exists for the tabRef
prop
The verification shows that the tabRef
prop is well-tested in packages/components/tabs/__tests__/tabs.test.tsx
. The test creates a ref using createRef<HTMLButtonElement>()
, passes it to the Tab component via tabRef
, and verifies that the ref is properly attached by checking that ref.current
is not null.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check if there are tests covering the new tabRef prop
# Look for test files related to tabs
rg -l "test|describe|it" packages/components/tabs/
# Look for existing test cases using refs in tabs
rg -A 5 "useRef|createRef|tabRef" packages/components/tabs/
Length of output: 3137
packages/components/tabs/src/tab.tsx (3)
4-4
: LGTM: Clean import addition
The mergeRefs utility is appropriately imported alongside related utilities.
47-47
: LGTM: Clean props addition
The tabRef prop is correctly destructured from the component props.
Line range hint 47-98
: Verify relation to test matcher warnings
While the implementation looks solid, could you clarify how these ref-related changes help prevent test matcher warnings? This would help ensure the changes align with the PR objectives.
apps/docs/content/docs/components/tabs.mdx (1)
Line range hint 1-400
: Documentation structure and content are well-organized.
The documentation is comprehensive and well-structured, covering installation, usage examples, accessibility, and API details. The addition of the tabRef
prop fits naturally within the existing structure.
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 a changeset
- any issue / linear page you can link?
- just wondering if it is a feat or fix? the title and the branch name are different.
|
* feat: add tab ref * feat: add changeset
fix: prevent test matcher warning
chore: add node types
chore: update Jest related packages
chore: run pnpm install
Summary by CodeRabbit
New Features
tabRef
property for the Tab component, allowing direct reference to the tab item.Bug Fixes
Documentation