Skip to content
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

Fix useDelete does not invalidate cache in pessimistic mode #10446

Merged
merged 5 commits into from
Jan 15, 2025

Conversation

fzaninotto
Copy link
Member

@fzaninotto fzaninotto commented Jan 14, 2025

Problem

Whe using pessimistic mode, a call to the delete callback of useDelete does not invalidate active queries.

As a consequence, lists aren't refreshed. This creates buggy behaior in some cases.

For instance, in a list where each row has a DeleteButton in pessimistic mode, clicking on a delete button properly removes the deleted row, but does not update the list, which therefore has less rows than the perPage.

Enregistrement.de.l.ecran.2025-01-14.a.22.13.54.mov

Solution

Related queries (getList, getMany, etc) are only invalidated on success on optimistic and undoable mode. They should be invalidated in all modes.

Enregistrement.de.l.ecran.2025-01-14.a.22.07.10.mov

How To Test

http://localhost:9010/?path=/story/ra-ui-materialui-button-deletebutton--in-list&args=mutationMode:pessimistic

Additional Checks

  • The PR targets master for a bugfix, or next for a feature
  • The PR includes unit tests (if not possible, describe why)
  • The PR includes one or several stories (if not possible, describe why)
  • The documentation is up to date

Sorry, something went wrong.

@fzaninotto fzaninotto added the WIP Work In Progress label Jan 14, 2025
@@ -330,13 +318,6 @@ export const useDelete = <
mode.current = mutationMode;
}

if (mode.current === 'pessimistic') {
Copy link
Member Author

Choose a reason for hiding this comment

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

moved down to allow snapshot (defined L350) to be accessible in pessimistic mode.

@djhi djhi merged commit 90c8bf4 into master Jan 15, 2025
16 checks passed
@djhi djhi deleted the fix-use-delete-pessimistic branch January 15, 2025 09:00
@djhi djhi modified the milestones: 5.4.5, 5.5.0 Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants