Skip to content

Fix useDelete does not invalidate cache in pessimistic mode#10446

Merged
djhi merged 5 commits intomasterfrom
fix-use-delete-pessimistic
Jan 15, 2025
Merged

Fix useDelete does not invalidate cache in pessimistic mode#10446
djhi merged 5 commits intomasterfrom
fix-use-delete-pessimistic

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

@fzaninotto fzaninotto added the WIP Work In Progress label Jan 14, 2025
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

Development

Successfully merging this pull request may close these issues.

2 participants