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.

https://i.sstatic.net/aNPUK.png

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

Restricting the input range with JQuery

Need assistance with limiting user input in a text box for amounts exceeding a specified limit. Attempted using Ajax without success, considering jQuery as an alternative solution. Any expertise on this matter? function maxIssue(max, input, iid) { v ...

Conceal an item if the span element encompasses a div with a specific class

I am struggling with a problem where I need to hide an "i" element only if a "span" contains a "div" element. The content inside the "span" is loaded via AJAX and rendered as HTML, so it may contain the "div class=difference" or not. The code snippet in q ...

What is the method for retrieving the state within the fetching action in redux-thunk?

I am just starting out with react. I have a product component in my react app that displays all the product items. The fetch function from the server is managed using redux-thunk. However, I am facing an issue where I cannot access the state in my componen ...

Eliminating the Skewed Appearance of Text in Input Fields Using CSS

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Customized Page Layout</title> <script src="https://c ...

Vue.js $scopedSlots do not function with Vue object

In the process of developing a Vue component that will be released once completed, I am wrapping Clusterize.js (note that the vue-clusterize component is only compatible with v1.x). The goal is to efficiently render a large list of items using Vue, particu ...

Is it possible to arrange a react map based on the length of strings?

I am working on a React function that loops through an object and creates buttons with text strings retrieved from the map. I want to display the text strings in order of their length. Below is the code snippet for the function that generates the buttons: ...

Is the Angular-fullstack generator production application experiencing issues with serving socket.io correctly?

Having a bit of trouble with two angular-fullstack apps deployed on AWS using the same setup and configuration. It appears that socket.io-client/socket.io.js is not being properly served on one of them, despite both apps having identical settings. There ...

Ionic 4: Facing issues with setting complete background image on ion-card

https://i.stack.imgur.com/3lH6h.png I'm currently attempting to set a background image for an Ion-card in order to completely cover the card's area. However, I'm facing an issue where the background image does not cover the entire area and ...

When should separate controllers be created for a list of values in a Laravel REST API?

Imagine I have a straightforward API for user registration. This API collects basic information like Name, email, state, gender, and marital status for each user. I already have database tables pre-populated with ids for state, gender, and marital status o ...

React-Markdown is throwing an error that states: "ES Module must be imported in order to load

Trying to integrate react-markdown into my Next.js project resulted in an immediate error when attempting to use it. Here is the code snippet: import React from 'react' import ReactMarkdown from 'react-markdown' export function Markd ...

Utilizing search parameters in React Router and extracting them for use

While trying to navigate from one page to another, I attempted to pass two values in the search parameter. Here is the code snippet that I used: this.props.history.push({ pathname:'/topics', search:'?lessonPl ...

Tips for sending multiple Formdata in a single array to an express backend

How can I efficiently send multiple form data as an array to my express backend? When I try creating an array of formData, I end up receiving an empty object in Express. Even the payload in the network tab appears empty. let arr1 = {data: []} let data1 = ...

Best practices for aligning the widths of input-group-addon elements

Hey there, I'm working with an HTML file that has 3 input options. Here's a snippet: <script type="text/ng-template" id="dashboard_assigngroup_popup.html"> <div class="modal-header modal-header2"> <h3 class="modal-tit ...

What is the best way to incorporate a button for toggling CSS animations?

I need help adding a button to toggle the animation on this JSFiddle. I tried adding the code below but can't seem to start and stop the animation. body .a [class^="b"] { width: 200px; height: 142.8571428571px; margin: 0 auto; ...

Sharing data with child components in Next.js through getStatisticProps

Is it possible to use getStaticProps only in the pages area, or can I also utilize a template from the components? I am looking to pass data from pages/index.js export default function Home({posts}) { return ( <div> <Head> ...

Is there a way to efficiently process multipart/formdata, application/json, and text/plain within a single Express handler?

Operating an express demo server that mirrors the client's POST requests back to it is a part of an educational practice. In this exercise, the client makes a POST request using the fetch API, like so: fetch('http://localhost:5000/', { m ...

Interacting with a button using Python Selenium while validating onFocus with JavaScript

I'm currently working on automating webpage navigation with Selenium in Python. My goal is to click on an HTML button that triggers JavaScript code to validate if the button is focused during the onclick action. Although I can successfully select a v ...

Encountering a 404 Error When Making an Ajax Request in Spring MVC

Looking to implement a basic login form using Spring MVC and an APIResponseModel class with Status, Message, HTTPStatus variables. After submitting the credentials, receiving a 404 ajax response, although the Controller returns {"status":"20 ...

The HTML generated by Selenium using Javascript is still missing some elements, despite accessing the document.body.innerHTML

Attempting to retrieve the HTML from a webpage that undergoes modification by JavaScript post-loading. Followed directions in this guide, executing the command below in my Python script after initial page load: html = browser.execute_script("return docume ...

Setting up React Context API with TypeScript: A Step-by-Step Guide

I recently updated my app.js file to app.tsx for improved functionality. However, I encountered an error with the current value. app.tsx import React, { createContext, useState } from "react"; import SelectPage from "./pages/select/select& ...