Skip to content

Conversation

m4theushw
Copy link
Collaborator

@m4theushw m4theushw commented Sep 7, 2021

Fixes #2508
Before: https://codesandbox.io/s/material-demo-forked-5u9pt?file=/demo.js
After: https://codesandbox.io/s/material-demo-forked-sw3r0?file=/demo.js

This bug is pretty interesting. Let's imagine that the first row is already selected. The selection and the focus are both listing to the click event. The user clicks into a different row and a rerender is triggered. While that, the focus state is also updated, which triggers another rerender. When the cell of the first selected row renders (it's not selected anymore) it still thinks that it has focus so it will call .focus(). The problem is that if this first cell is not visible, the browser will try to scroll to it. My fix is to pass an option to .focus to disable the scroll. This doesn't work in all browsers, so we use our own API to provide an alternative. I don't see a problem disabling the scroll, in this demo we're already not relaying on it but on the scroll APIs.

@m4theushw m4theushw added type: bug It doesn't behave as expected. scope: data grid Changes related to the data grid. type: regression A bug, but worse, it used to behave as expected. labels Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: data grid Changes related to the data grid. type: regression A bug, but worse, it used to behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[question] Issue with jumping x-grid starting from alpha.37

3 participants