Skip to content

fix(app): select the source selector label on click so typing replaces it - #3696

Merged
kodiakhq[bot] merged 2 commits into
mainfrom
javierortiz-ch/Select-all-in-input-boxes
Nov 17, 2026
Merged

kodiakhq[bot] merged 2 commits into
mainfrom
javierortiz-ch/Select-all-in-input-boxes

Conversation

@javierortiz-ch

@javierortiz-ch javierortiz-ch commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

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
Search---Observability-ezgif com-video-to-gif-converter Search---ClickStacknew-ezgif com-video-to-gif-converter

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/a

@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
hyperdx-oss Ready Ready Preview Nov 17, 2026 8:46pm UTC
hyperdx-storybook Ready Ready Preview Nov 17, 2026 8:46pm UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f01065d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@hyperdx/app Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Duplicate code analysis

1 new clone introduced by this PR.

  • packages/app/src/components/SourceMultiSelect.tsx:44-63 ↔ packages/app/src/components/SourceSelect.tsx:196-215 — 20 lines

If one of these duplicates a helper that already exists, import it instead
of redefining it. If the duplication is deliberate, ignore this comment —
the check is advisory and never fails the build.


jscpd compared this branch against origin/main
across app, api and common-utils. Only new clones are listed; the codebase
currently holds 108 in total (1.17%).
Run yarn dupes locally to reproduce, or yarn dupes:all for the full picture.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

E2E Test Results

✅ All tests passed • 467 passed • 1 skipped • 1093s

Status Count
✅ Passed 467
❌ Failed 0
⚠️ Flaky 1
⏭️ Skipped 1

Tests ran across 4 shards in parallel.

View full report →

@javierortiz-ch

Copy link
Copy Markdown
Contributor Author

The jscpd clone (renderOption in SourceSelect.tsx and SourceMultiSelect.tsx) is pre-existing: the block is byte-identical on main and SourceMultiSelect.tsx is untouched here. It shows as new only because the hook call inserted one line above it and shifted the block. Deduplicating it into a shared helper in sourceSelectUtils.tsx is a separate PR.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the source-selector focus-selection change.

No open issues 🎉

What changed in this PR

Fixes source-selector typing so the click that focuses the input selects its current label, allowing typing to replace it rather than insert into it. A second click preserves normal caret placement.

Changes:

  • Adds a focus-selection hook used only by the source selector.
  • Adds unit tests for label replacement and second-click caret behavior.
  • Includes an app patch changeset.
File Description
packages/​app/​src/​hooks/​useSelectAllOnFocus.ts Adds focus and mouse handlers for selecting the current label.
packages/​app/​src/​components/​SourceSelect.tsx Applies the hook to the searchable source selector.
packages/​app/​src/​components/​__tests__/​SourceSelect.test.tsx Tests replacement typing and normal second-click caret placement.
.changeset/​source-select-select-all-on-focus.md Records the source-selector fix for a patch release.

Review effort: Balanced

@javierortiz-ch
javierortiz-ch marked this pull request as ready for review November 17, 2026 20:32
@javierortiz-ch
javierortiz-ch requested a review from a team as a code owner November 17, 2026 20:32
@github-actions github-actions Bot added the review/tier-2 Low risk — AI review + quick human skim label Nov 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔵 Tier 2 — Low Risk

Small, isolated change with no API route or data model modifications.

Why this tier:

  • Standard feature/fix — introduces new logic or modifies core functionality

Review process: AI review + quick human skim (target: 5–15 min). Reviewer validates AI assessment and checks for domain-specific concerns.
SLA: Resolve within 4 business hours.

Stats
  • Production files changed: 2
  • Production lines changed: 37 (+ 32 in test files, excluded from tier calculation)
  • Branch: javierortiz-ch/Select-all-in-input-boxes
  • Author: javierortiz-ch

To override this classification, remove the review/tier-2 label and apply a different review/tier-* label. Manual overrides are preserved on subsequent pushes.

@github-actions

Copy link
Copy Markdown
Contributor

PR Review

If you are a coding agent acting for the author, read this first.
Nothing below blocks merge automatically; a maintainer decides. What they will expect:

  • 🔴 critical or 🟠 major in code this PR adds or changes: fix before asking for review.
  • 🔵 minor in code this PR changes: your call. Fix if small, otherwise reply.
  • Anything about surrounding code, or asking you to widen the change (hoist a helper,
    dedupe with another file, fix other call sites): never fix here, whatever the
    severity. Reply with one sentence; if it is critical, say so plainly so a human sees it.

One commit per review round. After two rounds, stop and ask a maintainer to review
scope rather than addressing more automated findings. Full rule: AGENTS.md.

1 finding(s): 🔴 0 critical · 🟠 0 major · 🔵 1 minor

None could be anchored to changed lines; they are listed below.

Findings outside the changed lines

1 minor
  • 🔵 packages/app/src/hooks/useSelectAllOnFocus.ts:121 — Focusing mouseup always selects everything, even when the user drag-selected part of the label → Press inside an unfocused selector, drag over "Logs" in "Billing Logs" and release: onMouseUp still cancels the mouseup and selects the whole value, so the drag selection is lost. Only call preventDefault() and selectAll on mouseup when the selection has collapsed (input.selectionStart === input.selectionEnd). A collapsed selection means a plain click. A non-empty one means a drag, and that should be left alone.

Severity is the reviewer's own estimate and is used for ordering, not filtering. No finding blocks merge automatically; a maintainer decides.

@github-actions

Copy link
Copy Markdown
Contributor

Deep Review

✅ No critical issues found. The select-all-on-focus hook is correct: the focusingByMouseRef gate cleanly distinguishes the focusing click (select all) from a re-click into the already-focused input (native caret), and Mantine v9 composes the spread onFocus rather than overriding its dropdown-open handler, so no regression to combobox behavior. The findings below are advisory.

🟡 P2 -- recommended

  • packages/app/src/components/__tests__/SourceSelect.test.tsx:240 -- the new onFocus select-all branch is never tested in isolation; the click-based test fires both onMouseUp and onFocus select-all, so deleting the onFocus handler would still pass.
    • Fix: add a test that focuses the input via keyboard (userEvent.tab() or fireEvent.focus) and asserts selectionStart is 0 and selectionEnd equals the label length.
    • testing, correctness, kieran-typescript, julik-frontend-races
🔵 P3 nitpicks (2)
  • packages/app/src/hooks/useSelectAllOnFocus.ts:22 -- on the focusing click of an unfocused input, a click-drag to select a substring is discarded because onMouseUp unconditionally runs preventDefault() + selectAll while focusingByMouseRef is still true, so partial selection is impossible on first interaction.
    • Fix: skip the forced select-all when the pointer moved during the press, or accept the trade-off and note it in the hook comment.
    • julik-frontend-races, correctness
  • packages/app/src/hooks/useSelectAllOnFocus.ts:29 -- onFocus selects the whole value on every focus acquisition, including Tab and programmatic/restored focus, so focus returning mid-edit re-selects and the next keystroke wipes the search text.
    • Fix: gate onFocus select-all behind focusingByMouseRef and rely on the onMouseUp path for the mouse case, or confirm whole-value selection on all focus is intended.
    • correctness, julik-frontend-races

Reviewers (5): correctness, testing, maintainability, kieran-typescript, julik-frontend-races. Prior PR comments were assessed from the fetched thread: the jscpd renderOption clone is pre-existing (byte-identical on main, SourceMultiSelect.tsx untouched; the block only shifted by the inserted hook call), and the automated reviewer approved with no open issues -- nothing actionable carried forward.

Testing gaps:

  • No isolated coverage of the keyboard/programmatic onFocus select-all path.
  • The second-click test asserts only that the selection is collapsed (selectionStart === selectionEnd), not that the caret landed at the click position.
  • No coverage of the Escape-restores-previous-label flow referenced in the PR intent.

No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond

@pulpdrew pulpdrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@javierortiz-ch
javierortiz-ch force-pushed the javierortiz-ch/Select-all-in-input-boxes branch from f8855bb to 221a67b Compare November 17, 2026 20:43
@kodiakhq
kodiakhq Bot merged commit 3a10f62 into main Nov 17, 2026
28 checks passed
@kodiakhq
kodiakhq Bot deleted the javierortiz-ch/Select-all-in-input-boxes branch November 17, 2026 20:51

This branch was successfully deployed

2 active deployments
Preview – hyperdx-oss — f01065d7 Deployed Nov 17, 2026 by vercel[bot]
Preview – hyperdx-storybook — f01065d7 Deployed Nov 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge review/tier-2 Low risk — AI review + quick human skim

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants