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

Fix #2963: Allow access to ref #2970

Closed
wants to merge 2 commits into from
Closed

Conversation

melloware
Copy link
Member

###Defect Fixes
Fix #2963: Allow access to ref

Many components were not forwarding the ref to the actual root elementRef of the component.

@melloware melloware requested a review from mertsincan June 7, 2022 13:05
@melloware melloware added the Status: Pending Review Issue or pull request is being reviewed by Core Team label Jun 7, 2022
@mertsincan
Copy link
Member

Hi @melloware,
I think we need to do a separate study for this. Maybe, all components can have two refs;

  • <Carousel ref -> ref.current.customWidgetVariable/Function
  • <Carousel elementRef -> elementRef.current (HTML dom element)

ref: component's ref
elementRef: DOM element's ref

WDYT?

@mertsincan mertsincan added the Status: Discussion Issue or pull request needs to be discussed by Core Team label Jul 1, 2022
@melloware
Copy link
Member Author

So here is what I did I found every component where its ref was showing as grey and unused in VS Code.

image

Then I simply followed your example in other places where you already had an elementRef I just simply assigned it to the variable the user wants so its passed through as the ref like in the DropDown case.

But we can handle it any way you think is best I just followed how you were doing it other components!

@melloware
Copy link
Member Author

Actually i think you might be right I am thinking that maybe we do this...

  1. ref is always pointed at useImperativeHandle in all components even if it has no widget methods to expose YET like this...
    React.useImperativeHandle(ref, () => ({
        ...props
    }));
  1. elementRef is always the root element of the component if its a DIV or SPAN or somethng.

@melloware melloware marked this pull request as draft July 8, 2022 11:40
@mertsincan
Copy link
Member

Yes, I'm thinking :D

@melloware
Copy link
Member Author

Closing this as its not the right PR.

@melloware melloware closed this Jul 9, 2022
@melloware melloware deleted the PR2963 branch September 27, 2022 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Discussion Issue or pull request needs to be discussed by Core Team Status: Pending Review Issue or pull request is being reviewed by Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Components: Cannot access ref
2 participants