Uncaught TypeError: Cannot set properties of null (setting 'scrollTop') #14987
Labels
bug 🐛
Something doesn't work
component: data grid
This is the name of the generic UI component, not the React module!
Link to live example: https://theodoremoreland.github.io/mui-x-data-grid-bug-demo/
The code can be found here: https://github.com/theodoremoreland/mui-x-data-grid-bug-demo/tree/updated-package-versions
This bug was actually discovered and reported by another person prior, but the thread was closed temporarily: #13301
The bug
When scrolling to the very bottom of the virtual scrollbar using a scroll wheel then decreasing the number of rows in a Data Grid via clicking a lesser page option or via programmatically deleting rows via some custom UI prompt (such as a Delete button) such that the vertical, virtual scroll bar is no longer needed, the Data Grid will throw the following error on
Chrome
:The following error on
Firefox
:OR
NOTE: Reproducing the error via programmatic deletion is inconsistent on Firefox (in my experience). However, the error occurs consistently in Chrome and in both browsers via decreasing page option.
Steps to reproduce
The conditions to reproduce the bug are very conditional, if not inconsistent. For example, from what I can tell:
Use case 1
NOTE: Oddly enough, scrolling to the bottom of the grid / virtual scrollbar
by clicking and dragging the scroll bar down does not produce an error nor does scrolling close to the bottom. The error is only produced by scrolling to the absolute bottom of the scrollbar via scroll wheel in this example.
If running the code locally, you should see an error popup in the UI. If running a deployed build, you may only see the error in the dev console.
Screenshots 1
Use case 2
NOTE: Weirdly enough, the following steps produce an error far more often
when using Google Chrome, in my experience. It may take multiple attempts
to get the error to produce in Firefox if at all.
If running the code locally, you should see an error popup in the UI. If running a deployed build, you may only see the error in the dev console.
Screenshots 2
A potential workaround
For some reason, how you render React's root DOM node can circumvent the error. For example, given "react": "^18.3.1" and "react-dom": "^18.3.1":
This does not work:
This does:
Current behavior
An error appears in the UI and in the dev console.
Expected behavior
Same functionality but without error message.
Context
I am trying to scroll to the bottom of the grid then proceed to decrease the number of rows displayed either via programmatic deletion or decreasing page options.
Your environment
npx @mui/envinfo
I have test Chrome and Firefox.
Search keywords: GridVirtualScrollbar data grid null scrolltop scroll
The text was updated successfully, but these errors were encountered: