The vertical scrolling functionality of the MUI DataGrid in Safari may occasionally fail to work

Utilizing the <Box> component from MUI core and the <DataGrid> component from MUIX, along with some other components, I have created a data grid that has the following appearance:

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

When the number of rows exceeds what can be displayed in the grid body, a vertical scrollbar should appear. However, this works as expected in Google Chrome (Beta, 102.0.5005.61) but fails to show up in Safari (15.4 (17613.1.17.1.13)). You can watch this video to see how attempting to scroll behaves like an unscrollable list in Safari even though there is overflow visible. The scrollbar only briefly appears when changing viewport height or refreshing until it reverts back to being unscrollable.

Is there a solution to correct this issue? It seems like there may be a minor error causing Safari to behave strictly while Chrome overlooks it.


I acknowledge that there may be details I have overlooked. Feel free to ask any questions for further clarification. In addition, two key points to note are:

  • The sorting and slicing of the list are handled server-side. Initially, the component renders empty columns, rows, null event listeners, etc., before fetching data upon loading.
  • The structure of the app components is outlined below:
const flexParent = { display: 'flex', flexDirection: 'column' };
const flexChild = { flexGrow: 1 };
<Box sx={{ height: '100vh', ...flexParent }}>
  <Container sx={{ ...flexChild, ...flexParent }}>
    <Box sx={{ maxHeight: '100%', ...flexChild, ...flexParent }}>
      <Box sx={{ ...flexChild, ...flexParent }}>
        <Box sx={{ ...flexChild }}>
          <Box sx={{ height: '100%', width: '100%' }}>
            <DataGrid
              loading={loading}

              // data: view
              columns={columns}
              rows={rows}

              // pagination: sorting
              sortingMode='server'
              sortModel={sortModel}
              onSortModelChange={changeOrder}

              // pagination: slicing
              paginationMode='server'
              rowCount={totalCount}
              rowsPerPageOptions={limitOptions}
              pageSize={limit}
              page={pageIndex}
              onPageChange={changePageIndex}
              onPageSizeChange={changeLimit}

              // styles
              disableColumnSelector
              disableDensitySelector
              hideFooterSelectedRowCount
              showCellRightBorder
              sx={{
                '.MuiDataGrid-cell, .MuiDataGrid-columnHeader': {
                  fontFamily: 'monospace',
                },
                '.MuiDataGrid-columnHeader:last-child .MuiDataGrid-columnSeparator': {
                  display: 'none',
                },
              }}
            />
          </Box>
        </Box>
      </Box>
    </Box>
  </Container>
</Box>

Answer №1

I have discovered a workaround that may not be favored by everyone.

The issue seems to stem from the initial rendering of the component with empty data, which is later fetched and rendered again with non-empty data shortly after.

It appears that this process creates a race condition internally, causing the component to mistakenly believe there are no rows to scroll through when in fact there are many.

To resolve this, I implemented key={Math.random()} in the grid component to force it to re-render every time there is a change:

<DataGrid
  key={Math.random()}
  columns={columns}
  rows={rows}
/>

This ensures that any residual effects from the previous state are eliminated, maintaining a consistent component state.

While this solution may be resource-intensive, it has been effective for me given the limited need for re-rendering. It could potentially work for you as well.

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

Using the information retrieved from Google Place Autocomplete and saving it for future reference

I am interested in utilizing the Google API "Place Autocomplete" widget to enhance user experience on my website. The specific widget I have in mind can be found here. My goal is to streamline the process of obtaining property addresses from Real Estate A ...

Tips on Implementing a CSS Variable in a React Component

Is there a way to use content variable with in-line styles in React? I am unsure of how to accomplish this. CSS3 .right::after, button::after { content: var(--content); display: block; position: absolute; white-space: nowrap; padding: 40px 40p ...

Example of Image Slider using AngularJS

<body ng-app="myApp"> <div ng-controller="slideShowController" class="imageslide" ng-switch='slideshow' ng-animate="'animate'"> <div class="slider-content" ng-switch-when="1"> <img src="../images/ship.png" /> & ...

Reducing the amount of text displayed on ion-text to a minimum

HTML: <ion-list *ngFor="let message of messages"> <ion-item lines="none" type="button" button="true"> <ion-grid> <ion-row> <ion-col class="message"> <ion-text> ...

The Updating Issue: Angular 2 Table Fails to Reflect Value Changes

I have initialized a table with user details using the ngOnInit() method. When I click on the "create user" button, it opens a form to add a new user to the database. However, the table does not update automatically with the new user's information. H ...

Displaying default tab content while hiding other tab content in Javascript can be achieved through a simple code implementation

I have designed tabs using the <button> element and enclosed the tab content within separate <div></div> tags like shown below: function displayTab(evt, tabName) { var i, tabcontent, tablinks; tabcontent = document.getElementsB ...

When employing GraphQL Apollo refetch with React, the update will extend to various other components as well

My current setup involves using react along with Apollo. I have implemented refetch in the ProgressBar component, which updates every 3 seconds. Interestingly, another component named MemoBox also utilizes refetch to update the screen at the same int ...

Getting a file object with v-file-input in Nuxt.js

For my Nuxt.Js apps, I utilized Vuetify.js as the UI framework. In order to obtain the file object when uploading files, I incorporated the v-file-input component from Vuetify.js and wrote the following code snippet: <template> <div> ...

Is there a way to transfer an element from one row to another using Bootstrap?

Can the grid layout transition smoothly from a desktop view to a mobile view using Bootstrap 4 or pure CSS flex classes? Desktop view: Mobile view : Currently, I have a solution in place but I want to avoid repeating content in two different places. Is ...

Moving your cursor over the text will eliminate the border of the <img> located directly above it

Check out the latest products here! <ul class="products"> <li class="product first"> <a href="http://www.gwendolynbarnes.com/product/finis/"> <img width="117" height="150" src="http://www.gwendolynbarnes.co ...

What is a sleek method for including a key and value pair to an object using an array?

In a project using angular2/typescript, I am working with an array of objects that contain key/value pairs from a database. These values are then displayed in a table on the UI using ag-grid-ng2. The table headers are dynamic and set in the database. One ...

Is there a way to retrieve the requested data in useEffect when using next.js?

As a newcomer to next.js and TypeScript, I am facing an issue with passing props from data retrieved in useEffect. Despite my attempts, including adding 'return scheduleList' in the function, nothing seems to work. useEffect((): (() => void) = ...

Retrieve the TaskID of an ECS Fargate container for exporting and future use within AWS CDK code

Currently, I am leveraging CDK version 2 alongside Typescript. In my current setup, I encounter a situation where I necessitate the TaskID value from ECS Fargate Container to be incorporated into another command. The process involves me utilizing new ecs ...

My page is experiencing delays due to setInterval

Currently, I am delving into the world of Chrome Extension development and am faced with a roadblock in replacing elements on a live chat page. While most of my tasks are running smoothly, the one thing causing issues is the setInterval option that trigger ...

I encountered a problem where the error "Type '(err: Error) => void' does not possess any properties similar to type 'QueryOptions'" appeared, and I am unsure of the underlying cause

Check out my route for removing a user: https://i.stack.imgur.com/fevKI.png I've set up a route called "/deleteuser" that uses the POST method. It validates the request body for an id and then proceeds to delete the user with that ID from the databas ...

Dispersed data points within ng2-charts

After reviewing the ng2-charts documentation at , unfortunately, I did not come across any information regarding a Scattered Plot. Are there alternative methods to create a Scattered plot chart in ng2-charts? Any helpful tricks or customization options a ...

A guide on incorporating unique font weights into Material UI

Looking to customize the Material theme by incorporating my own font and adjusting the font weights/sizes for the Typography components. I am attempting to set 100/200/300/400/500/600/700 as options for each specific typography variant, but it seems that o ...

Loading identical code in two different div elements

I am in the process of designing a comprehensive resource database featuring a side-scrolling container. Once a user clicks on a thumbnail within the container, the contents of a corresponding div will fade in and display specific category content. Each di ...

Webpack bundling only a singular Typescript file rather than all of its dependencies

I'm currently facing a challenge while attempting to consolidate all the files in my Typescript project, along with their dependencies from node_modules, into a single file using Webpack. Despite trying multiple options, it seems that only the entry f ...

What steps do I need to take to design a menu?

I need assistance in organizing my menu with submenus. The code I currently have successfully retrieves all the submenus, but I would like to categorize them accordingly: For instance: Main Menu - Submenu 1, Submenu 2, Submenu 3 How can I go about categ ...