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

#726: Add support for forwarding refs to cell components #727

Merged
merged 1 commit into from
Aug 22, 2024

Conversation

gersongoulart
Copy link
Contributor

@gersongoulart gersongoulart commented Aug 15, 2024

Description

Add support for forwarding refs to cell components, allowing for external control or access to the DOM element rendered by the cell.

  • Refactored the component to function-style so as to utilize React.forwardRef, enabling the ability to pass a ref to the cell component
  • Ensured that the ref is attached to the top-level div element rendered by the cell, enabling usage of ref-based methods or direct DOM manipulation.
  • Maintained existing prop-types while supporting the new ref forwarding functionality.
  • Verified that existing usage patterns of the component remain unaffected by these changes.

Motivation and Context

Resolves #726

How Has This Been Tested?

Tested using npm run test and by using npm link to use the enhanced component in my project, effectively resolving the issue.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Support forwarding refs to cell components, allowing access to the DOM element rendered by the cell.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.

…allowing for external control or access to the DOM element rendered by the cell.

- Refactored the component to function-style so as to utilize `React.forwardRef`, enabling the ability to pass a `ref` to the cell component
- Ensured that the `ref` is attached to the top-level `div` element rendered by the cell, enabling usage of ref-based methods or direct DOM manipulation.
- Maintained existing prop-types while supporting the new `ref` forwarding functionality.
- Verified that existing usage patterns of the component remain unaffected by these changes.
@pradeepnschrodinger
Copy link
Collaborator

Hi, thanks for the PR!
Our company is on holiday worldwide this week, so I'll be a bit slow to respond.

Upon converting to a function component, the use of React.findDOMNode will no longer work, as it is designed for class components only. This is a breaking change. Passing a ref prop is now required in order to access the underlying DOM node.

Could you explain how this'll be a breaking change for the user?
I can't think of an existing case that'll be broken by this change.

@gersongoulart
Copy link
Contributor Author

gersongoulart commented Aug 19, 2024

Hi, thanks for the PR! Our company is on holiday worldwide this week, so I'll be a bit slow to respond.

No worries.

Could you explain how this'll be a breaking change for the user? I can't think of an existing case that'll be broken by this change.

@pradeepnschrodinger, my bad. While working on my app, I did see a failure while using React.findDOMNode with a ref pointing to the component itself. But passing the new ref (a DOM node) directly to it works fine. While elaborating an answer, I was unable to reproduce the issue — it must've happened in some weird intermediary code change. False alarm! I'll change the description. Thanks for catching that.

Copy link
Collaborator

@pradeepnschrodinger pradeepnschrodinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@pradeepnschrodinger pradeepnschrodinger merged commit 5a28e3b into schrodinger:master Aug 22, 2024
6 checks passed
@pradeepnschrodinger
Copy link
Collaborator

Released with v2.0.13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support forwarding refs to cell components, allowing access to the DOM element rendered by the cell.
2 participants