Closed javismiles closed 3 years ago
👋 Thanks for using Material-UI!
We use GitHub issues exclusively as a bug and feature requests tracker, however, this issue appears to be a support request.
For support, please check out https://material-ui.com/getting-started/support/. Thanks!
If you have a question on StackOverflow, you are welcome to link to it here, it might help others. If your issue is subsequently confirmed as a bug, and the report follows the issue template, it can be reopened.
Tip, RootRef is deprecated, the Dialog portal its element, the ref might only be accessible after the did mount hook.
@oliviertassinari Thank you, I switched to normal ref yes, the main issue seems to be that componentDidUpdate() is not firing after render of the material-ui list is completed, but before. I can prove this by using plain javascript: var scrollPos= document.getElementsByClassName("MuiDialog-paper"); This returns undefined after componentDidUpdate fires. Yet it returns the correct value later on after a few seconds. It seems to me that componentDidUpdate is firing incorrectly in conjuntion with this material-ui component thank you
It's possible, the Modal portals it's element, the ref might only be available after.
@oliviertassinari This is the way I made it work
componentDidUpdate() {
setTimeout(function(){
var scrollPos= document.getElementsByClassName("MuiDialog-paper");
if (scrollPos.length>0){scrollPos[0].scrollTop=0;}
}, 200);
}
That works perfect. It is certainly a very absurd way, but the only way I found. Seems like the rendering of the list goes beyond useEffect, componentDidUpdate etc firings, so the only way is to wait x time to then check things out, etc
It would be great if the documentation maybe provided some suggestion to detect the full completed rendering of material-ui components such as List, etc
thank you
@oliviertassinari I get that you don't consider this to be a bug, got it, but it surely is something to be polished regarding either the component or its documentation. Being able to truly detect full rendering completion is key to for example set the scrollTop, etc. I shouldn't have to hack my way with setTimeout and plain javascript to make it work.
Good day,