Commit 1cc2ce6
authored
Fix tiny UI race after add SSH key in instance create form (#3177)
It's barely worth fixing, but codex flagged it in #3173 and it's real.
Watch the `select all` checkbox below when I submit the create SSH key
form. In the very short interval of time after the key is created and
but before list of keys refetches, the select all checkbox flashes
checked (all are selected) before flipping back to intermediate when the
list comes in. It's trivial and it's not worth keeping the e2e test I
used to prove and fix it (removed in
966aac1), but it is worth fixing now
that I know about.
https://github.com/user-attachments/assets/0bc9e5ff-ceb0-49b5-856d-8998a8971528
The checkbox showing the wrong thing is not actually the entire bug — if
the user toggles select all during this interval, the behavior is
slightly weird because the list of keys is out of sync, but it's nearly
impossible for a human user to move fast enough to run into the issue,
and the state after the request comes back will be up to date. The real
fix would be to make `onSuccess` wait until after the invalidate is
complete. But we don't have any other examples of `async onSuccess`, so
I don't want to rush that fix in.
```diff
const handleDismiss = onDismiss ? onDismiss : () => navigate(pb.sshKeys())
const createSshKey = useApiMutation(api.currentUserSshKeyCreate, {
- onSuccess(sshKey) {
- queryClient.invalidateEndpoint('currentUserSshKeyList')
+ async onSuccess(sshKey) {
+ await queryClient.invalidateEndpoint('currentUserSshKeyList')
onSuccess?.(sshKey)
handleDismiss()
// prettier-ignore
```1 parent 0df8ff0 commit 1cc2ce6
File tree
3 files changed
+38
-2
lines changed- app
- components/form/fields
- util
3 files changed
+38
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
76 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
77 | 87 | | |
78 | 88 | | |
79 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
12 | 19 | | |
13 | 20 | | |
14 | 21 | | |
| |||
73 | 80 | | |
74 | 81 | | |
75 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
76 | 94 | | |
77 | 95 | | |
78 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
52 | 60 | | |
53 | 61 | | |
54 | 62 | | |
| |||
0 commit comments