Commit 6647808
fix(sidebar): stop the workspace switcher stranding a phantom hover (#6096)
* fix(sidebar): stop the workspace switcher stranding a phantom hover
The switcher's keyboard cursor is set from `onMouseMove` and only cleared
when the menu closes, and it paints in `--surface-active` — the same token
hover uses. So the last row the pointer crossed keeps a background
indistinguishable from hover long after the pointer has gone, sitting
alongside the equally-`--surface-active` current workspace as a second
phantom-hovered row. It shows without any hovering too: the cursor is
seeded to row 0 on open, so any user whose current workspace is not first
sees two marked rows immediately. Only bites above the 3-workspace search
threshold, which is why it went unnoticed.
Paint the cursor only while the user is actually navigating by keyboard.
Arrow keys enter that mode, any pointer motion leaves it, so in pointer
mode the sole mark is real CSS :hover — which follows the pointer and
leaves with it. `highlightedId` still tracks the pointer, so Enter keeps
targeting the row last touched; only whether it is drawn changes.
This is the pattern emcn's own popover already uses (`isKeyboardNav`,
commented "prevent dual highlights") and that `tag-dropdown` consumes, and
it matches how Headless UI models a combobox: one modality-driven focus
marker, separate from the selected value. The list carries no
`aria-activedescendant`/`aria-selected`, so the highlight is purely visual
and nothing in the a11y contract changes.
* test(sidebar): assert the keyboard cursor on a row that isn't selected
Review round 1: the keyboard-positive assertions landed on the current
workspace, which carries its own `isActive` fill, so they held whether or
not the cursor was painted — the tests could not have caught deleting
keyboard-cursor rendering.
Navigate with ArrowUp instead, wrapping from the seeded first row to the
last, and assert on that row. Verified both directions now: removing the
modality gate reddens three tests, removing keyboard painting reddens two.
* fix(sidebar): do not arm Enter without a visible target
Review round 1: gating the cursor's paint on keyboard mode left Enter still
acting on the seeded first row while that row was unmarked. The search
field takes focus on open, so Enter could switch workspace with nothing
shown as the target — emcn's popover instead holds its selection at -1 and
ignores Enter until keyboard nav begins.
Enter now acts only once a cursor is on screen, and typing counts as
keyboard intent so the common "filter, then Enter" flow lands on a visible
top result. Every path to Enter therefore has a marked target.
---------
Co-authored-by: Waleed Latif <waleed@simstudio.ai>1 parent d95127d commit 6647808
2 files changed
Lines changed: 273 additions & 3 deletions
File tree
- apps/sim/app/workspace/[workspaceId]/w/components/sidebar/components/workspace-header
Lines changed: 237 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 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 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 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 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
Lines changed: 36 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
172 | 185 | | |
173 | 186 | | |
174 | 187 | | |
| |||
228 | 241 | | |
229 | 242 | | |
230 | 243 | | |
| 244 | + | |
231 | 245 | | |
232 | 246 | | |
233 | 247 | | |
| |||
526 | 540 | | |
527 | 541 | | |
528 | 542 | | |
529 | | - | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
530 | 549 | | |
531 | 550 | | |
532 | 551 | | |
533 | 552 | | |
534 | 553 | | |
535 | 554 | | |
| 555 | + | |
536 | 556 | | |
537 | 557 | | |
538 | 558 | | |
539 | 559 | | |
| 560 | + | |
540 | 561 | | |
541 | 562 | | |
542 | 563 | | |
543 | 564 | | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
544 | 570 | | |
545 | 571 | | |
546 | 572 | | |
| |||
562 | 588 | | |
563 | 589 | | |
564 | 590 | | |
565 | | - | |
| 591 | + | |
566 | 592 | | |
567 | 593 | | |
568 | 594 | | |
| |||
575 | 601 | | |
576 | 602 | | |
577 | 603 | | |
578 | | - | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
579 | 612 | | |
580 | 613 | | |
581 | 614 | | |
| |||
0 commit comments