question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scroll to top of Dialog

See original GitHub issue
  • [ x] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

I’m rendering a pretty long component within the dialog, and am using the autoscroll functionality to get the overflow-y: auto styling in the dialog content. At certain points, the component moves to the the next step, and I would like to instantly go to the top of the dialog content.

I saw that jQuery’s scrollTop function can be used to get to the top of a component, but I’m unsure how to reference the dialogContent div. Please advise.

Current Behavior

Currently, when the component changes, the scroll remains the same, and the result is that the user sees a lower part of the new component.

Your Environment

Tech Version
Material-UI 0.17.4
React 15.3.2
browser Chrome
etc

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

22reactions
m2mathewcommented, Nov 17, 2017

If you want to manipulate the scrollPosition yourself programmatically, you need to use the Ref Callback pattern to have access to that DOM element directly.

Check StackOverflow and similar sources for other questions on how to use the library. 😄

9reactions
DzTheRagecommented, Mar 8, 2019

I was able to get this working using @achikin solution. Just nest a div inside of dialog content then render another dialog content.

<DialogContent>
   <div ref={node => {
	this.dialogContent = node;
      }}>
	<DialogContent className={classes.fixContentPadding}>
		Actual Content Here
	</DialogContent>
    </div>
</DialogContent>

handleNext = () => {
    /* Smooth scroll to top */
    this.dialogContent.scrollIntoView({
	behavior: 'smooth',
	block: 'start'
     });
    /* Go to next step */
     const { activeStep } = this.state;
     this.setState({
     activeStep: activeStep + 1
     });
};

	

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get jQueryui dialog scrollTop to scroll dialog content to ...
Try $("#the_dialog_div").scrollTop("0"). This worked for me!
Read more >
Scroll to top of Dialog · Issue #9186 · mui/material-ui - GitHub
I saw that jQuery's scrollTop function can be used to get to the top of a component, but I'm unsure how to reference...
Read more >
How to scroll on the top of modal - Salesforce Stack Exchange
i have a modal popup with scrolling, i am trying to scroll the user to the top of the modal when the user...
Read more >
scrollbar positioned at top of dialog after scrollTop()
I launch a jQuery UI modal Dialog containing an iframe. The contained document has anchors with corresponding navigational links. When a link is ......
Read more >
modal scrolls to top (I explain why) - WordPress.org
The browser (chrome in my case) scrolls to the top because you've set the height of the content to the same as the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found