Commit 5d611d6
Forms: Add notice after optimistic response status update (#46056)
* optimizations from review
* add notice to pending action and update load state logic
* changelog
* fix js tests
* fix issue with wrong page loaded on undo
* fix premature removal of pending actions
* Fix UI flicker when undoing status change actions
Fixes a race condition where clicking undo immediately after marking a
response as spam/trash would cause the UI to flicker. The item would
briefly disappear and reappear, and checkboxes would flash on all entries.
Root cause: When undo was clicked, the original action's API response
would arrive after the undo's optimistic update, overwriting it with
stale data. This created a sequence where the UI would update to the
wrong state (spam) before correcting itself (publish).
Solution: Make undo wait for the original action's refetch to complete
before starting. Implemented by:
- Tracking pending refetch promises in a Map by actionId
- Making undo onClick async and awaiting the original refetch
- Using undoTriggered flag to skip refetch if undo clicked quickly
- Removing original pending action state before starting undo
This ensures only one refetch result is applied, eliminating the flicker
while keeping undo responsive.
---------
Co-authored-by: William Viana <vianasw@gmail.com>1 parent dfe0943 commit 5d611d6
File tree
10 files changed
+658
-287
lines changed- projects/packages/forms
- changelog
- src/dashboard
- hooks
- inbox/stage
- store
- tests/js/dashboard/components
- empty-spam-button
- empty-trash-button
10 files changed
+658
-287
lines changedLines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
Lines changed: 26 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
92 | 99 | | |
93 | 100 | | |
94 | 101 | | |
| |||
146 | 153 | | |
147 | 154 | | |
148 | 155 | | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | 156 | | |
163 | 157 | | |
164 | 158 | | |
| |||
178 | 172 | | |
179 | 173 | | |
180 | 174 | | |
181 | | - | |
182 | | - | |
183 | | - | |
| 175 | + | |
184 | 176 | | |
185 | 177 | | |
186 | 178 | | |
| |||
243 | 235 | | |
244 | 236 | | |
245 | 237 | | |
246 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
247 | 245 | | |
248 | 246 | | |
249 | 247 | | |
| |||
0 commit comments