Commit a4c76cb
authored
fix: Show pending revocation on click (#38184)
## **Description**
This PR improves the user experience when revoking Gator permissions by
adding optimistic UI feedback.
**What is the reason for the change?**
When users clicked the "Revoke" button for a Gator permission, there was
a noticeable delay before the button appeared disabled and showed
"Pending..." text. This created a poor user experience where users might
click multiple times, unsure if their action was registered.
**What is the improvement/solution?**
The solution implements optimistic UI feedback by:
1. Immediately setting a pending state when the revoke button is clicked
2. Disabling the button and displaying "Pending..." text right away
3. Managing the pending state with a 800ms timeout after the revoke
operation completes to prevent visual flashing before the transaction
confirmation window appears
4. Properly cleaning up timeouts on component unmount to prevent memory
leaks
5. Immediately clearing the pending state if an error occurs
The implementation uses local component state (`pendingRevokeClicks`)
combined with the existing global pending revocations selector to
provide a smooth, responsive user experience.
[](https://codespaces.new/MetaMask/metamask-extension/pull/38184?quickstart=1)
## **Changelog**
CHANGELOG entry: Improved responsiveness of revoke button in Gator
permissions by adding immediate UI feedback
## **Manual testing steps**
1. Go to all permissions
2. Find a permission
3. Click revoke -> the button should turn to pending revocation right
away, before the revoke transaction window shows.
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
https://github.com/user-attachments/assets/7e111d41-3857-44a0-84ea-7569af0f9e01
### **After**
https://github.com/user-attachments/assets/5c222555-8f0d-4dc5-b70e-247350024cdd
<!-- [screenshots/recordings] -->
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Adds optimistic pending state for Gator permission revocations,
disabling the button and showing "Pending..." immediately with timeout
cleanup.
>
> - **UI — Gator Permissions**
> - `review-permissions/review-gator-permissions-page.tsx`:
> - Introduces local pending state via `pendingRevokeClicks` (Set) and
`revokeTimeoutsRef` (Map) with unmount cleanup.
> - Updates `handleRevokeClick` to optimistically set pending, call
`revokeGatorPermission`, then clear after 800ms; clears immediately on
error.
> - Passes `hasRevokeBeenClicked` to children; simplifies empty-state
check to `gatorPermissions.length`.
> - `components/review-gator-permission-item.tsx`:
> - Adds optional `hasRevokeBeenClicked` prop and integrates it into
`isPendingRevocation` alongside global `pendingRevocations`.
> - Disables Revoke button and switches label to pending when either
local or global pending is true.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
f675d88. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 718bbf7 commit a4c76cb
File tree
2 files changed
+98
-31
lines changed- ui/components/multichain/pages/gator-permissions
- components
- review-permissions
2 files changed
+98
-31
lines changedLines changed: 12 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
76 | 81 | | |
77 | 82 | | |
78 | 83 | | |
| |||
102 | 107 | | |
103 | 108 | | |
104 | 109 | | |
| 110 | + | |
105 | 111 | | |
106 | 112 | | |
107 | 113 | | |
| |||
151 | 157 | | |
152 | 158 | | |
153 | 159 | | |
154 | | - | |
155 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
156 | 165 | | |
157 | | - | |
| 166 | + | |
158 | 167 | | |
159 | 168 | | |
160 | 169 | | |
| |||
Lines changed: 86 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
2 | 8 | | |
3 | 9 | | |
4 | 10 | | |
| |||
65 | 71 | | |
66 | 72 | | |
67 | 73 | | |
68 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
69 | 106 | | |
70 | 107 | | |
71 | 108 | | |
| |||
100 | 137 | | |
101 | 138 | | |
102 | 139 | | |
103 | | - | |
104 | | - | |
105 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
106 | 148 | | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
119 | 176 | | |
120 | 177 | | |
121 | 178 | | |
122 | 179 | | |
123 | 180 | | |
124 | 181 | | |
125 | 182 | | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
136 | 194 | | |
137 | 195 | | |
138 | 196 | | |
| |||
162 | 220 | | |
163 | 221 | | |
164 | 222 | | |
165 | | - | |
| 223 | + | |
166 | 224 | | |
167 | 225 | | |
168 | 226 | | |
| |||
0 commit comments