Skip to content

[WEB] deselect grid rows (delete action) and create control to save column display (in memory) - #47

Open
willferreiras wants to merge 3 commits into
masterfrom
web-refactor-datatable-rows-delete
Open

[WEB] deselect grid rows (delete action) and create control to save column display (in memory)#47
willferreiras wants to merge 3 commits into
masterfrom
web-refactor-datatable-rows-delete

Conversation

@willferreiras

Copy link
Copy Markdown
Contributor

No description provided.

@willferreiras willferreiras changed the title Web refactor datatable rows delete [WEB] deselect grid rows (delete action) and create control to save column display (in memory) Dec 31, 2022

@giorgiofellipe giorgiofellipe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, maybe would make sense to reduce localStorage reads from row 178 to row 193, to something like this:

      const storagePageSize = localStorage.getItem(`${storageKey}-page-size`);
      if () {
        const parsedPageSize = parseInt(localStorage.getItem(`${storageKey}-page-size`) || '', 0);
        setPageSize(parsedPageSize);
      }
...

Comment thread packages/web/components/DataTable/index.tsx Outdated
Comment thread packages/web/components/DataTable/index.tsx Outdated
.catch();

localStorage.setItem(`${storageKey}-filters`, JSON.stringify({}));
setFilters({});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why filters are being cleared on row deletion?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original bug is from MuiDataTable itself and this was the only way to fix it here on our side. If the user filtered by a situation (active for example) selected one or more records from the grid and deleted them, the grid would bug (it kept the selected records, but without listing the deleted ones because it was filtering by assets). Applying this change to clear filters when deleting a row resolved the issue.

Comment thread packages/web/components/DataTable/index.tsx
setPageSize(storagePageSize);
const storagePageSize = localStorage.getItem(`${storageKey}-page-size`);
if (storagePageSize) {
const parsedPageSize = parseInt(localStorage.getItem(`${storageKey}-page-size`) || '', 0);

@giorgiofellipe giorgiofellipe Jan 16, 2023

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const parsedPageSize = parseInt(localStorage.getItem(`${storageKey}-page-size`) || '', 0);
const parsedPageSize = parseInt(storagePageSize || '', 0);

Apply to the others as well. please test it carefully

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants