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

Filter is not working to exclude actions from undo/redo history #306

Open
1 of 4 tasks
dmathisen opened this issue Aug 16, 2023 · 3 comments
Open
1 of 4 tasks

Filter is not working to exclude actions from undo/redo history #306

dmathisen opened this issue Aug 16, 2023 · 3 comments

Comments

@dmathisen
Copy link

dmathisen commented Aug 16, 2023

I'm submitting a ...

  • Bug report
  • Feature request
  • Docs update
  • Support request => Please do not submit support requests here, see note at the top of this template.

What is the current behavior/state of the project?

The filter property seems to be broken.

What is the desired behavior?

Reducers listed in the filter array should be ignored from undo/redo history.

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via a gist or similar.

Reproduceable in this CodeSandbox.
In this example, the 2nd number has a filter to exclude the action (see store.ts filter: excludeAction(["increment2", "decrement2"])). So I would expect the 2nd number to NOT be affected by undo/redo, but it is.

image

Please tell us about your environment:

  • Library version: 1.1.0
  • Redux version: 8.1.2
  • Browser: all
  • Language: TypeScript 5.1.6

Note: there's a (maybe) related issue filed a long time ago and it says that the issue may have been introduced in 1.0.0-beta8, but I haven't been able to verify.

@kartGRAM
Copy link

kartGRAM commented Mar 3, 2024

Isn't there an error in the following section, and shouldn't it be like this instead?
excludeAction(["counter/increment2", "counter/decrement2"])
https://codesandbox.io/p/sandbox/rtk-redux-undo-example-forked-6h6gwh

@dmathisen
Copy link
Author

dmathisen commented Mar 5, 2024

@kartGRAM Perhaps, but clicking UNDO in your example still undoes the increment2/decrement2 actions, so it's still not working.

EDIT: The behavior is odd. If I only do the increment2/decrement2 actions, it doesn't undo. But then I do increment1/decrement1 and when I click UNDO, increment2/decrement2 resets to 0. Maybe it's just a bug in my code example. I'll dig in more. But I think your solution could be correct.

@chenzhutian
Copy link

I also have the similar bug

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

No branches or pull requests

3 participants