When cycling through search results with arrow keys, the caret gets moved #171
Labels
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Grandiras/Ponente#171
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When cycling through search results with arrow keys, the carot gets movedto When cycling through search results with arrow keys, the caret gets moved🤖 On it — follow along in the action run; the reply will link the full session transcript.
📜 Live transcript — updating every ~5 minutes while the task runs.
Pushed to
claude/issue-171.What was wrong
The search panel's up/down keys are handled in C# (
SearchBox.OnKeyDown), and nothing ever calledpreventDefaulton them. So the browser did what an arrow means in a text field as well as moving the active row:ArrowDownthrew the caret to the end of the query,ArrowUpto the start. Look down the results, go back to fix a letter, and the correction lands in the wrong place.Why the fix is in JS
A Blazor handler can't decide
preventDefaultper key —@onkeydown:preventDefaultis read at render time, so the flag would have to be set before the keystroke it applies to, and it suppresses every key in the field, letters included. So the state stays exactly where it was and only the key's browser meaning moves:search-interop.jsis now handed the input element along with theDotNetObjectReference, and callspreventDefault()onArrowUp/ArrowDownaimed at that field. Blazor's own handler still runs — the caret moves after the event, not during it.[role="option"]), which is the C# switch's_hits.Count > 0read off the markup rather than copied into the browser — the two can't disagree. With no list under the field, the arrows are the caret's again.Files:
wwwroot/js/search-interop.js,Components/Layout/SearchBox.razor,tests/e2e/search.spec.js,docs/search.md.Verified
Ran the app (
dotnet run, Development, local Postgres 15) and drove it with Playwright 1.62.1 —search.spec.js, all 3 tests green. The new assertions in the keyboard block:ArrowDownactivates row 2, caret still 3 →ArrowUpactivates row 1, caret still 3ArrowUpstill moves the caret to 0Both halves fail on the unfixed code, checked by disabling the new branch:
Expected: 3, Received: 22— the caret at the end of the query, which is the bug.dotnet buildclean,dotnet test Ponente.sln448/448 (includesDocumentationTests).No changelog entry: the search box itself is still in
Changelog.Unreleased, so no member ever saw the broken behaviour — a bullet describing it would be describing something that never shipped.⏱ 7m 50s · 54 turns · tokens: 82.5k in / 24.5k out (+3645.8k cache-read)
📜 Full session transcript
→ Opened PR: #174