# FIX: discourse-reactions rollback not working

**URL:** https://meta.discourse.org/t/fix-discourse-reactions-rollback-not-working/392855
**Category:** Bug
**Tags:** reactions
**Created:** [January 7, 2026, 7:24am UTC](https://meta.discourse.org/t/fix-discourse-reactions-rollback-not-working/392855 "2026-01-07T07:24:28Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![small-lovely-cat](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/small-lovely-cat/32/553546_2.png) [@small-lovely-cat](https://meta.discourse.org/u/small-lovely-cat)
#### Post date: [January 7, 2026, 7:24am UTC](https://meta.discourse.org/t/fix-discourse-reactions-rollback-not-working/392855/1 "2026-01-07T07:24:28Z")

</div>

The discourse-reactions plugin has a rollback function, when the `toggle.json` request fails, the page should rollback the reactions to the original state.

However, the function is broken, and the original `_rollbackState()` function never works as the state itself changes when `toggleReaction` is called. And the reaction state never goes back without refreshing/reloading the window, leading to the heart/reactions leaving on the page even when the request failed.

This commit fixs this by adding a new function `_captureState()`, keeping the state in a const value, and revert it to the page data when necessary.

[https://github.com/discourse/discourse/pull/36989](https://github.com/discourse/discourse/pull/36989)

---

<div class="post-metadata">

### Author: ![martin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/martin/32/491371_2.png) [@martin](https://meta.discourse.org/u/martin)
#### Post date: [January 7, 2026, 7:31am UTC](https://meta.discourse.org/t/fix-discourse-reactions-rollback-not-working/392855/2 "2026-01-07T07:31:16Z")

</div>

Thank you, I have approved 👍

---

<div class="post-metadata">

### Author: ![martin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/martin/32/491371_2.png) [@martin](https://meta.discourse.org/u/martin)
#### Post date: [January 8, 2026, 4:24am UTC](https://meta.discourse.org/t/fix-discourse-reactions-rollback-not-working/392855/4 "2026-01-08T04:24:13Z")

</div>

It was just a flaky spec, I have merged the PR now 🙂

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [January 13, 2026, 11:52am UTC](https://meta.discourse.org/t/fix-discourse-reactions-rollback-not-working/392855/5 "2026-01-13T11:52:46Z")

</div>


