mui / material-ui

Material UI: Comprehensive React component library that implements Google's Material Design. Free forever.
https://mui.com/material-ui/
MIT License
93.74k stars 32.24k forks source link

can't get the origin ref of the DialogContent component; #8904

Closed tun100 closed 6 years ago

tun100 commented 6 years ago

Hi, I'm develop a material-ui project. And It's almost done, but there's something is not suit for user to use.

Dialogs component is Good to select value of a list, but if the selected value control is the last index component of the list, and the list total item length is very big. When I reopen the list component, I want to make the parent component scrollTop position to target select item offsetTop.

And I want to set scrollTop to the parent component DialogContent, to get te ref element and set scrollTop by js. But I don't know where should to get the origin element.

I find a way to get ref, it's look likes:

<DialogContent ref={
  node=>{
    this.node = node;
  }
}

But when I inspect it by console.log, it's ref props is undefined, and seems it's not origin HTML5 element.

Sorry to push this issue, I really need help, Could you tell me how to get the origin HTML5 element?Thanks a lot.

oliviertassinari commented 6 years ago

The component is exposed as a class. The ref callback should be working as expected. https://github.com/callemall/material-ui/blob/9ea0d4d67dd8d3f2c9f8602856655bfd07fc70ea/src/Dialog/DialogContent.js#L51

Sorry, but this issue isn't following our template. Nor it's providing a full reproduction example. I'm closing.

ghost commented 6 years ago

Try wrapping it in a to enable you get a ref to the DialogContent. Docs available at https://material-ui.com/api/root-ref/

`

Some content

`