-
Notifications
You must be signed in to change notification settings - Fork 609
fix(Stack): correctly forward a Ref #6111
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: ee7e43e The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks! |
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.
Pull Request Overview
This PR ensures that both Stack
and StackItem
components correctly forward refs to their underlying DOM elements by wrapping them in forwardRef
.
- Imported and applied
forwardRef
toStack
- Imported and applied
forwardRef
toStackItem
- Adjusted prop types to include ref props
Comments suppressed due to low confidence (1)
packages/react/src/Stack/Stack.tsx:130
- [nitpick] The parameter name
forwardRef
shadows the importedforwardRef
function and is inconsistent with theStack
component’sforwardedRef
. Consider renaming this parameter toforwardedRef
.
forwardRef: React.Ref<HTMLDivElement> | undefined,
Co-authored-by: Copilot <[email protected]>
size-limit report 📦
|
packages/react/src/Stack/Stack.tsx
Outdated
className, | ||
...rest | ||
}: StackProps<As> & React.ComponentPropsWithRef<ElementType extends As ? As : 'div'>, | ||
forwardedRef: React.Ref<HTMLDivElement> | undefined, |
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.
I think the type for this will get tricky because the forwardRef
type should match whatever As
is and I believe with the setup now it would always be HTMLDivElement
.
The way this is typed also seems to be making the props inferred as any
so they won't show up in autocomplete / won't fail if passed the wrong value (let me know if you're not seeing this locally though, could be something on my end)
<Stack
as="span"
ref={node => {
// `node` is `HTMLDivElement` instead of `HTMLSpanElement`
}}
// I don't think this will fail TS now the way the types are inferred
gap="nonsense"
/>
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.
Good catch! I didn't notice 😅. I think I fixed it now, lmk what you think!
Co-authored-by: Josh Black <[email protected]>
👋 Hi, there are new commits since the last successful integration test. We recommend running the integration workflow once more, unless you are sure the new changes do not affect github/github. Thanks! |
👋 Hi, there are new commits since the last successful integration test. We recommend running the integration workflow once more, unless you are sure the new changes do not affect github/github. Thanks! |
👋 Hi, there are new commits since the last successful integration test. We recommend running the integration workflow once more, unless you are sure the new changes do not affect github/github. Thanks! |
👋 Hi, there are new commits since the last successful integration test. We recommend running the integration workflow once more, unless you are sure the new changes do not affect github/github. Thanks! |
👋 Hi, there are new commits since the last successful integration test. We recommend running the integration workflow once more, unless you are sure the new changes do not affect github/github. Thanks! |
👋 Hi from github/github! Your integration PR is ready: https://github.com/github/github/pull/380422 |
🔴 golden-jobs completed with status |
Closes #5446
Changelog
New
Stack
andStackItem
in forwardRef callRollout strategy
Testing & Reviewing
Merge checklist