Material User Interface, MUI, Modal, Back to Top Scroll按钮

After spending some time experimenting with scrollTop and the Dialog component (a fullscreen fixed modal) from Material-ui, I found that I couldn't quite get scrollTop to function properly. Whenever I clicked the "go down" button, it would either return undefined or not work at all within the scrollable container.

Answer №1

Everything required had already been provided

Ensure that the Dialog contains overflow

<Dialog fullScreen open={open} onClose={handleClose}>
        <div ref={ref}  
//VITAL
 style={{ backgroundColor: 'red', overflowY: 'auto', height: '100%' }}>

**Plus an onClick function **

<Button
autoFocus
color="inherit"
//ADDING HERE
onClick={() => {
const div = ref.current;
div.scrollTop = 800;
}}
>GO DOWN
</Button>

Take a look at this sample https://codesandbox.io/s/fullscreendialog-material-demo-forked-cf8u6?file=/demo.js:2201-2434

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The design preview in Android Studio fails to showcase Material Design elements

I've created a basic CardView using androidx.cardview.widget.CardView Now, I'm attempting to switch to CardView based on com.google.android.material.card.MaterialCardView, but the preview mode doesn't show any results How can I resolve thi ...

Displaying Unicode CSS Font Awesome Icons as Boxes in a React Project

I have incorporated the jPlayer example into a create-react-app. Encountering an issue where font-awesome icons are displaying as boxes in this CodeSandbox illustration. https://codesandbox.io/s/peaceful-heisenberg-d59nz?fontsize=14&hidenavigation=1&a ...

What are the best techniques for streamlining nested objects with Zod.js?

As a newcomer to zod.js, I have found that the DataSchema function is extremely helpful in verifying API data types and simplifying the API response easily. However, I'm curious if there is a way to streamline the data transformation process for myEx ...

Exploring the process of retrieving outcomes from Node.js within a Knockout ObservableArray

Below is the Node.js code snippet I have: var http = require('http'); var port = process.env.port || 1337; var MovieDB = require('moviedb')('API KEY'); MovieDB.searchMovie({ query: 'Alien' }, function (err, res) { ...

Selecting a date in a pop-up

In my PHP application, I have incorporated a date selection feature within a modal dialog. However, when clicking the control, the calendar appears in the left corner of the page and remains visible even after selecting a date. Additionally, clicking elsew ...

Having trouble extracting the date modified from a JSON file

I am able to retrieve section name, URL, web title, and headline from parsing JSON data with this code snippet. However, I seem to be encountering an issue where I cannot extract the last modified date. Here is the JSON structure: { "response":{ ...

The display of JSON data is not loading properly

Having some trouble displaying data in my app. Not sure if I'm missing something or making a mistake. Check out my code below. Projects.js: import Res2 from './images/Res/res2.jpg' import Res3 from './images/Res/res3.jpg' import ...

What are the steps for utilizing JSON data retrieved from an ajax response?

After successfully making an ajax request and receiving JSON data, I am struggling with how to use it effectively. The response I am getting looks like this: [{ "id": "5", "reviewID": "2389", "serviceID": "50707", "title": "well d ...

What is the best way to customize the endIcon of a styled-component button?

Presented here is a neatly styled button I've created import styled from 'styled-components'; import Button from '@material-ui/core/Button'; import ArrowForwardIosIcon from '@material-ui/icons/ArrowForwardIos'; const MyB ...

Utilizing jQuery to implement a function on every individual row within a table

I have a collection of objects that requires applying a function to each item, along with logging the corresponding name and id. Below is the snippet of my code: var userJson = [ { id: 1, name: "Jon", age: 20 }, { ...

How can I merge these two Observables in Angular to create an array of objects?

Let's say we are working with two different datasets: student$ = from([ {id: 1, name: "Alex"}, {id: 2, name: "Marry"}, ]) address$ = from([ {id: 1, location: "Chicago", sid: 1}, {id: 2, location: &qu ...

Is there a way to automatically convert a webpage to a PDF when it is requested?

I'm looking to convert the webpage into a PDF file upon request. Below are the scripts I am using: <script> pdfdoc.fromHTML($('#container').html(), 10, 10, { 'width': 110, ...

Is there a way to align this in a horizontal inline block?

I have this element and I would like it to display inline-block but horizontally. Currently, it is displaying as inline-block but vertically. Here is my HTML: <div class="ondisplay"> <div class="left-text"> <p&g ...

Customizing date colors in JavaScript: A step-by-step guide

var active_dates1 = ["2017-04-02 00:00:00","2014-04-03 00:00:00","2014-04-01 00:00:00"]; $('.datePick', this.$el).datepicker( beforeShowDay: function (date) { for(let date1 of active_dates1){ if (date.getTime( ...

JSX Bootstrap unresolved arror

I have been using Bootstrap with React, but the compiler keeps failing due to unterminated JSX contents. I have checked my code numerous times and can't seem to find any unclosed tags no matter how the ternary operator evaluates. As a beginner in Reac ...

The particles.js with absolute positioning is currently overlapping my div with relative positioning

Visit this link <div class="outer-container"> <div id="particles-js"> <div class="your-content"> <article id="3" class="bg-dusk transition md:group-hover:opacity-50 md:hover:opacity-important md:hov ...

Exploring the dynamic loading of components within routes

Just starting out with Vue and experimenting with vue-router, I'm trying my hand at dynamically loading components without relying on additional libraries like webpack. So far, I've set up an index page and a router. Upon initial page load, I not ...

Tips for updating the URL in the browser address bar after loading content using AJAX with angular.js

When developing a web application using angular.js, the communication within the app is done through AJAX. This means that when the application requests web resources, the URL in the browser address bar does not change. For instance, my app displays build ...

Why is it impossible for me to delete the class / property of this object?

Within a series of nested divs, there are additional divs containing multiple imgs. The goal is to cycle through these images using CSS transitions. To achieve this, a JavaScript object was created to track the divs, sub-divs, and images. Three arrays were ...

MUI Backdrop - Utilizing it as a custom hook results in it being displayed on the screen even when the open parameter is set to false

I initially placed the Backdrop directly in the component and everything was functioning properly. However, for reusability purposes (especially considering the nature of react), I decided to create a custom hook with the Backdrop. I ran into an issue wher ...