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

Failed to ref to Allotment.Pane #582

Closed
huoyingyangjie opened this issue Mar 30, 2023 · 3 comments · Fixed by #632
Closed

Failed to ref to Allotment.Pane #582

huoyingyangjie opened this issue Mar 30, 2023 · 3 comments · Fixed by #632
Assignees

Comments

@huoyingyangjie
Copy link

Is it by design or is it a bug?

@johnwalley
Copy link
Owner

Sounds like a bug. A ref to the underlying div is exposed:

Screenshot 2023-04-26 at 22 15 11

Could you provide a reproduction so I can diagnose the issue?

@EFF
Copy link

EFF commented May 3, 2023

@johnwalley Having the same issue here, paneRef is always undefined.

const MyParentComponent = () => {
  const paneRef = useRef<HTMLDivElement>(null) // not working
  const myComponentRef = useRef(null) // obv works
  const allotmentRef = React.useRef<AllotmentHandle>(null) // works
  
  return (
   <Allotment
     onChange={(size) => { /* some handler */}}
     ref={allotmentRef} // this one works
     >
       <Allotment.Pane ref={paneRef}> /* always undefined */
           <MyComponent ref={myComponentRef} /> /* this is my workaround */
        </Allotment.Pane>
  )
}

Experienced the issue on 1.17.1 and 1.19.0
Note that in my case this pane is 3 Allotment deep

@johnwalley johnwalley self-assigned this Jun 27, 2023
@johnwalley johnwalley linked a pull request Jun 27, 2023 that will close this issue
@johnwalley
Copy link
Owner

I just had a quick look at this. I'm having some success with a change like this: #632. But I'll need to determine in more depth if it's correct (and work out what the correct types are).

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

Successfully merging a pull request may close this issue.

3 participants