-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[data grid] Lag while typing #5283
Comments
Could you provide a minimal reproduction example? I tried to run your code But of course nobody can knows what is behind those lines except you import Loading from "../../../Components/Loading.component";
import { UserContext } from "../../../Context/User/UserContext.context";
import Movie from "../../Domain/Domain-Model/Entities/Movie.model";
import MovieRepository from "../../Domain/Domain-Service/Repository/Implementation/movie.repository.service";
import Genre from "../../Domain/Domain-Model/Entities/Genre.model"; |
https://drive.google.com/file/d/19VhT6-CgfbdRVb1Hg4rqBWXSh_hCqSZb/view Take a look on this video, I was Trying to write: Hola cómo estás, but it got some lag and deleted some words |
I do not doubt you are experiencing lags, but without a reproduction, we can not know which feature slows down the component, and so we are not able to fix it It's probably not the newEditingApi alone or the number of rows, because it runs without problems in the following codesandbox with 500 rows https://codesandbox.io/s/basiceditinggrid-demo-mui-x-forked-1my45w?file=/demo.tsx Could you provide the version of the package you are using to verify we did not add some perf improvement between your version and the last one Maybe @m4theushw has already seen this problem in another issue |
Some of my users report this issue with editing of simple text fields too. The tables have all about 60-100 rows and 12 columns. Most columns render simple text or links (some with This means I have a total of two text columns and select columns, that can be edited per row. All of those have a simple valueSetter: (
params: GridValueSetterParams<MyGridRowData, string>,
) => {
// my_field is only there, because it is easier to access in DataGrid
// it's proper place is in sub_element
const my_field = params.value
let sub_element: TeaserInfo | undefined
if (params.row.sub_element) {
sub_element = params.row.sub_element
sub_element.my_field = my_field
}
return { ...params.row, my_field, teaser }
}, |
Some more testing yielded: if I set The problem always starts, when you hit the Maybe the solution would be to only trigger |
@TheRealCuran could you provide a reproduction? I can't know if you're using cell editing or row editing. |
@m4theushw I use only cell editing (users double click into a cell and can change its value). The reproducer will take me until tomorrow at least, might become next week. Need to sanitize the internal code in a way that I can share and still shows the issue. Apart from that, I can upgrade "some of my users" to "all users" of this internal tool. All of them are using the latest Firefox on Mac OS; but I do see this issue on Linux (latest Firefox) as well. Just to make sure this is now bug in Firefox, I did test Chromium as well and saw the same issue. |
I "fixed" it by removing the ExperimentalApi and using onRowEditStop instead. I didn't know how to solve it without removing that. Though. I've also added a SearchaBar to the GridToolBar and it also has typing issues. I have noticed that it has some delay when the field checks the spelling. |
@alexfauquette @m4theushw I am experiencing a similar issue that I think may be a repro of what the OP is talking about. Randomly while editing a cell a character will get deleted. It happens so quickly it is hard to tell if it actually happened, but I was able to capture it in a screen recording. Repro: https://codesandbox.io/s/quizzical-sky-ez5zql?file=/src/App.js During second 2 of the video below if you scrub slowly you can see a Q is typed and then quickly erased although the backspace button was not pressed. Watching in real time you can hardly tell it was typed at all. Screen.Recording.2022-07-08.at.6.19.54.PM.mov |
I solved the issue for myself. Firefox Profiler to the rescue: I had an Ajv validator function that got in the way. I mean it schouldn't have been executed anyway, but since we go through the |
I've noticed that this issue appears pretty often when running my app in debug mode, however it is very rare in prod builds. Unfortunately I do not have time to attempt to create a reproducer right this moment |
@bimbiltu The repro I posted above has nothing to with any components other than the grid. Not sure if thats what you were saying, but this is happening in isolation of the grid. |
@colespencer1453 I spent a while playing with the link you posted and got the same issue to reproduce, but its very infrequent for me. I have to fill in the cell maybe 20-30 times very quickly to get it to happen. I was hoping to come up with a more reliable reproducer (its very easy to repro inside my app), but what you linked does show the bug for me as well |
@m4theushw I'd love to bump this issue. I'm seeing this pretty consistently and it is super annoying. Has anybody on the mui-x team not observed this behavior? |
@colespencer1453 I managed to reproduce it by increasing CPU throttling in Chrome DevTools. But I'm still investigating it. |
I opened #5646 with a potential fix for this bug. Could anyone check if it solves the problem? The docs for the PR is https://deploy-preview-5646--material-ui-x.netlify.app/x/react-data-grid/editing/. Opening any demo in CodeSandbox will automatically use the package with the fix. You can also use this package in your application. It's very hard to reproduce this bug, even using CPU throating, so I had to force a delay to test locally. |
@m4theushw that PR appears to solve the issue for me |
Corrected to |
I think I've experienced same behaviour as described in #5283 (comment) Screen.Recording.2022-08-17.at.18.13.03.movYou can slow down the video to make sure that I type "hello" each time by looking at the virtual keyboard. I've managed to create an e2e test to reproduce the issue: diff --git a/test/e2e/fixtures/DataGrid/GridEditing.tsx b/test/e2e/fixtures/DataGrid/GridEditing.tsx
new file mode 100644
index 0000000..63ef0d2
--- /dev/null
+++ b/test/e2e/fixtures/DataGrid/GridEditing.tsx
@@ -0,0 +1,19 @@
+import * as React from 'react';
+import { DataGrid, GridColumns, GridRowsProp } from '@mui/x-data-grid';
+
+const columns: GridColumns = [{ field: 'name', headerName: 'Name', width: 600, editable: true }];
+
+const rows: GridRowsProp = [
+ {
+ id: 1,
+ name: 'Name',
+ },
+];
+
+export default function BasicEditingGrid() {
+ return (
+ <div style={{ height: 300, width: '100%' }}>
+ <DataGrid rows={rows} columns={columns} experimentalFeatures={{ newEditingApi: true }} />
+ </div>
+ );
+}
diff --git a/test/e2e/index.test.ts b/test/e2e/index.test.ts
index a7aceec..0ad431a 100644
--- a/test/e2e/index.test.ts
+++ b/test/e2e/index.test.ts
@@ -350,5 +350,30 @@ describe('e2e', () => {
await page.evaluate(() => (document.activeElement as HTMLInputElement).value),
).to.equal('0-1');
});
+
+ it.only('should not swallow letters during cell editing', async () => {
+ await renderFixture('DataGrid/GridEditing');
+
+ await page.click('[role="cell"][data-field="name"]');
+
+ await page.keyboard.down('Backspace');
+ await sleep(300);
+
+ await page.keyboard.down('Digit1');
+ await sleep(30);
+
+ await page.keyboard.down('Digit0');
+ await sleep(210);
+
+ await page.keyboard.down('Digit1');
+ await sleep(35);
+
+ await page.keyboard.down('Digit0');
+ await sleep(300);
+
+ expect(
+ await page.evaluate(() => (document.activeElement as HTMLInputElement).value),
+ ).to.equal('1010');
+ });
});
}); Few takeaways:
I'll check if #5646 makes the test pass. UPDATE: the test above fails starting from this commit c049e3a. It passes on the commit before (17a2570) and I cannot reproduce the issue manually too. UPDATE 2: the test seems to pass on #5646 rebased onto master |
[Preface: I am no longer affected directly by this issue, since I've found a workaround. Feel free to ignore my input below.] @bimbiltu writes:
If you take that away from my post, you didn't read it properly, IMHO. The page itself is fine and the Ajv validation should only happen on network traffic and even then there should never have been a recompilation of the validation function, but for whatever reason (again, I haven't gone done that rabbit hole, since there was an easier solution for relatively modern hardware – not optimal by any means, since I am sure this is still somehow going through validation/Ajv when it shouldn't) it triggered a recompilation of the Ajv validation function. Having the That being said: by having a static Ajv function, compiled during commit, that is only annoying myself, I managed to get below the threshold of the typing speed my users have. Therefore I cannot reproduce this issue in production any longer. Still, going through large parts of the callback chain seems excessive for each keystroke. If the PR is reducing the amount of callback executions to the bare minimum, it is certainly going to help. Anyway, feel free to merge, I didn't see any reduction in performance for the users here. |
@cherniavskii I tried your test case. It failed on |
Fixed by #5646 |
Hello, @m4theushw! Is it fixed in DataGridPremium? I have same problem with quick filter with and without debouncer. It's rarely reproduced in production and more often in dev build. |
@m4theushw, thank you for your attention! 6783 |
Duplicates
Latest version
Current behavior 😯
when I double-click on a cell that I want to edit when typing the component has a certain delay that erases words and does not allow me to type correctly
Expected behavior 🤔
I wish to write: Hello, how are you?
Datagrid cell: Hllo, ow re yo
Steps to reproduce 🕹
import { Alert, AlertProps, Box, Button, debounce, IconButton, Snackbar, Stack } from '@mui/material';
import { DataGrid, GridCellEditStopParams, GridCellEditStopReasons, GridColumns, GridRowModel, GridSelectionModel, GridToolbar, MuiEvent, useGridApiContext } from '@mui/x-data-grid';
import DeleteIcon from '@mui/icons-material/Delete';
import { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react'
import Loading from '../../../Components/Loading.component';
import { UserContext } from '../../../Context/User/UserContext.context';
import Movie from '../../Domain/Domain-Model/Entities/Movie.model';
import MovieRepository from '../../Domain/Domain-Service/Repository/Implementation/movie.repository.service';
import Genre from '../../Domain/Domain-Model/Entities/Genre.model';
import { randomId } from '@mui/x-data-grid-generator'
const useChangeValidation = () => {
return useCallback(
(movie: Partial) =>
new Promise<Partial>((resolve, reject) =>
setTimeout(() => {
console.log(" useChangeValidation")
/* if (movie.title === '') reject(new Error(
Error saving ${movie.idMovie}, it can not be empty
))else resolve({ ...movie, title: movie.title });
if (movie.director === '') reject(new Error(
Error saving ${movie.idMovie}, it can not be empty
))else resolve({ ...movie, director: movie.director });*/
resolve({ ...movie, director: movie.director })
}, 0),
),
[],
);
};
export const MovieTable = (props: any) => {
const [columns, setColumns] = useState<GridColumns>([]);
const [rows, setRows] = useState<any[]>([])
const [movie_repository] = useState(new MovieRepository());
const [user] = useContext(UserContext)
const mutateRow = useChangeValidation();
const [snackbar, setSnackbar] = useState<Pick<AlertProps, 'children' | 'severity'> | null>(null);
const handleCloseSnackbar = () => setSnackbar(null);
const [selectionModel, setSelectionModel] = useState([]);
const rowsRef = useRef(rows);
}
Context 🔦
No response
Your environment 🌎
npx @mui/envinfo
Order ID 💳 (optional)
No response
The text was updated successfully, but these errors were encountered: