[Bug]: Ref Is Not Passed To Column With Css-grid Mode
Introduction
In this article, we will discuss a bug that has been observed in the @carbon/react
package, specifically in the Column
component when using the css-grid
mode. The issue is that the ref
is not passed properly to the Column
component when using css-grid
mode, whereas it is passed correctly when using the flex-grid
mode. We will explore the issue in detail, provide a reproduction example, and discuss the suggested severity and potential workarounds.
Problem Description
The problem is that when using the css-grid
mode in the Column
component, the ref
is not passed to the component. This is in contrast to the flex-grid
mode, where the ref
is passed correctly. The ref
is only passed to the flex-grid-style
component, and passing a component with a ref
to the as
prop does not seem to work as a workaround.
Reproduction Example
To reproduce the issue, you can use the following example:
https://stackblitz.com/edit/github-umzfckpc?file=src%2FApp.jsx
This example demonstrates the issue by creating a React ref and passing it to the Column
component in css-grid
mode. However, the ref
is undefined, indicating that the issue is not resolved.
Steps to Reproduce
To reproduce the issue, follow these steps:
- Create a React ref using the
useState
hook or thecreateRef
method. - Pass the ref to the
Column
component incss-grid
mode. - Observe that the ref is undefined.
Suggested Severity
The suggested severity of this issue is Severity 2, which means that the user cannot complete the task, and/or there is no workaround within the user experience of a given component.
Workarounds
Unfortunately, there are no known workarounds for this issue. However, we can discuss potential solutions and possible fixes.
Potential Solutions
One potential solution is to modify the Column
component to pass the ref
to the css-grid
component. This would require changes to the Column
component's code and may involve additional dependencies.
Another potential solution is to use a different component or library that supports passing refs
to css-grid
components.
Conclusion
In conclusion, the ref
is not passed to the Column
component when using the css-grid
mode in the @carbon/react
package. This issue is not resolved in the current version of the package, and there are no known workarounds. We have discussed potential solutions and possible fixes, but further investigation and testing are required to determine the best course of action.
Recommendations
Based on the analysis of this issue, we recommend the following:
- Modify the
Column
component to pass theref
to thecss-grid
component. - Use a different component or library that supports passing
refs
tocss-grid
components. - Further investigate and test potential solutions to determine the best course of action.
Future Development
In the future, we recommend that the @carbon/react
package team addresses this issue and provides a fix or workaround. This will ensure that users can use the Column
component with css-grid
mode without encountering this issue.
Code of Conduct
We agree to follow the project's Code of Conduct and have checked the current issues for duplicate problems.
Package
- @carbon/react: 11.82.1
- React: 1.82.1
Browser
- No response
Description
We observe that ref is passed properly when using FlexGrid but not CSS Grid. Please see example for details.
Reproduction/example
https://stackblitz.com/edit/github-umzfckpc?file=src%2FApp.jsx
Steps to reproduce
- Create react ref.
- Pass it inside Column component of 'css-grid' mode
- ref is undefined
Suggested Severity
Severity 2 = User cannot complete task, and/or no workaround within the user experience of a given component.
Application/PAL
No response
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
- [x] I checked the current issues for duplicate problems
Q&A: Bug: ref is not passed to Column with css-grid mode =====================================================
Q: What is the issue with the Column component in css-grid mode?
A: The issue is that the ref
is not passed to the Column
component when using the css-grid
mode in the @carbon/react
package. This is in contrast to the flex-grid
mode, where the ref
is passed correctly.
Q: Why is this issue only occurring in css-grid mode?
A: The issue is only occurring in css-grid
mode because the ref
is only passed to the flex-grid-style
component, and not to the css-grid
component.
Q: What are the steps to reproduce this issue?
A: To reproduce the issue, follow these steps:
- Create a React ref using the
useState
hook or thecreateRef
method. - Pass the ref to the
Column
component incss-grid
mode. - Observe that the ref is undefined.
Q: What is the suggested severity of this issue?
A: The suggested severity of this issue is Severity 2, which means that the user cannot complete the task, and/or there is no workaround within the user experience of a given component.
Q: Are there any known workarounds for this issue?
A: Unfortunately, there are no known workarounds for this issue. However, we can discuss potential solutions and possible fixes.
Q: What are some potential solutions to this issue?
A: One potential solution is to modify the Column
component to pass the ref
to the css-grid
component. This would require changes to the Column
component's code and may involve additional dependencies.
Another potential solution is to use a different component or library that supports passing refs
to css-grid
components.
Q: What is the recommended course of action for this issue?
A: Based on the analysis of this issue, we recommend that the @carbon/react
package team addresses this issue and provides a fix or workaround. This will ensure that users can use the Column
component with css-grid
mode without encountering this issue.
Q: How can I contribute to the solution of this issue?
A: If you are a developer or a contributor to the @carbon/react
package, you can help to solve this issue by:
- Reporting the issue and providing a reproduction example.
- Contributing to the development of a fix or workaround.
- Testing and verifying the solution.
Q: What is the Code of Conduct for this project?
A: We agree to follow the project's Code of Conduct and have checked the current issues for duplicate problems.
Package
- @carbon/react: 11.82.1
- React: 1.82.1
Browser
- No response
Description
We observe that ref is passed properly when using FlexGrid but not CSS Grid. Please see example for details.
Reproduction/example
https://stackblitz.com/edit/github-umzfckpc?file=src%2FApp.jsx
Steps to reproduce
- react ref.
- Pass it inside Column component of 'css-grid' mode
- ref is undefined
Suggested Severity
Severity 2 = User cannot complete task, and/or no workaround within the user experience of a given component.
Application/PAL
No response
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
- [x] I checked the current issues for duplicate problems