Repository navigation
Commit 3a10f62
authored
fix(app): select the source selector label on click so typing replaces it (#3696)
## Summary
The source selector is a searchable Mantine Select, and clicking it puts the caret wherever the pointer lands inside the current label. Typing `Data plane` over `ControlPlane Logs` produces `ControlData planePlane Logs`, the dropdown filters to nothing, and the user has to clear the box by hand before every switch.
This PR selects the whole label on the click that focuses the selector, so typing replaces it. **A second click into an already focused selector places the caret as usual**, and Escape or clicking away still restores the previous label. The handlers live in `useSelectAllOnFocus` and only `SourceSelectControlled` uses them, so the aggregation, database, table and filter dropdowns are unchanged. A unit test pins replace-on-click and the second-click caret.
### Screenshots or video
Not captured: this change was made without a browser. A short video of click-then-type on the source box shows it best.
| Before | After |
| :----- | :---- |
| <img width="800" height="450" alt="Search---Observability-ezgif com-video-to-gif-converter" src="https://github.com/user-attachments/assets/492957a0-261e-43cf-90d9-4b89dc46531f" /> | <img width="800" height="450" alt="Search---ClickStacknew-ezgif com-video-to-gif-converter" src="https://github.com/user-attachments/assets/4a5847f1-f926-4a5a-9f18-4ea52271efa4" /> |
### How to reproduce
**Starting point:** https://play.hyperdx.io/search, or `yarn app:dev:local` connected to the demo server.
**On `main`:**
1. Click in the middle of the source selector text (placeholder **Data Source**), between two letters of the current source name.
2. Type `tra`.
3. The box shows the old name with `tra` inserted in the middle and the dropdown has no matching source.
**On this branch:**
1. Click anywhere in the source selector text.
2. The whole name is highlighted. Type `tra`.
3. The box shows only `tra` and the dropdown lists the sources whose name or section contains it.
4. Click the box again: the caret lands where you clicked instead of selecting all.
5. Press Escape: the previous source name is back.
### How to test on Vercel preview
**Preview routes:** /search
**Steps:**
1. Click in the middle of the source selector input with placeholder **Data Source**.
2. Type `tra`.
3. Verify the input value is exactly `tra` and the dropdown lists at least one source whose name contains "Tra".
4. Press Escape and verify the input shows the previously selected source name again.
### References
- Linear Issue: n/a
- Related PRs: n/a1 parent 50129d1 commit 3a10f62
4 files changed
Lines changed: 74 additions & 1 deletion
File tree
- .changeset
- packages/app/src
- components
- __tests__
- hooks
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
192 | 193 | | |
193 | 194 | | |
194 | 195 | | |
| 196 | + | |
195 | 197 | | |
196 | 198 | | |
197 | 199 | | |
| |||
249 | 251 | | |
250 | 252 | | |
251 | 253 | | |
| 254 | + | |
252 | 255 | | |
253 | 256 | | |
254 | 257 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| 186 | + | |
186 | 187 | | |
187 | 188 | | |
| 189 | + | |
188 | 190 | | |
189 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
190 | 194 | | |
191 | 195 | | |
192 | 196 | | |
| |||
233 | 237 | | |
234 | 238 | | |
235 | 239 | | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
236 | 266 | | |
237 | 267 | | |
238 | 268 | | |
| |||
| 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 | + | |
0 commit comments