Skip to content

Comments

Fix: double-click + backspace clears only one char in text inputs#189

Open
StephaneDelcroix wants to merge 1 commit intomainfrom
fix/when-creating-a-new-session-double-click-20260223-0926
Open

Fix: double-click + backspace clears only one char in text inputs#189
StephaneDelcroix wants to merge 1 commit intomainfrom
fix/when-creating-a-new-session-double-click-20260223-0926

Conversation

@StephaneDelcroix
Copy link
Collaborator

Bug

When creating a new session, double-clicking the session name entry selects the full name, but pressing backspace only clears one character instead of the full selection. Same issue in rename inputs.

Root Cause

@onkeydown on value-bound inputs triggers a Blazor re-render before the browser processes the keystroke. The re-render writes back element.value, which clears the browser's text selection. When backspace then fires, there's no selection to delete — only one character is removed.

Fix

Change @onkeydown to @onkeyup on all value-bound text inputs. @onkeyup fires after the browser's default action, so the selection is preserved and multi-character delete works correctly.

Affected inputs:

  • CreateSessionForm.razor: session name, worktree branch, worktree PR
  • SessionListItem.razor: rename input
  • SessionCard.razor: rename input

Non-value-bound inputs (Dashboard/SessionSidebar group name inputs) are unaffected and left unchanged.

Tests

Added InputSelectionTests.cs with:

  • Convention test scanning all .razor files for value-bound inputs with @onkeydown (prevents regression)
  • Specific tests verifying each fixed input uses @onkeyup

Change @onkeydown to @onkeyup on value-bound text inputs (session name,
rename, worktree branch/PR). @onkeydown triggers a Blazor re-render
before the browser processes the keystroke, which writes back
element.value and clears the text selection. @onkeyup fires after the
browser's default action, preserving selection behavior.

Affected inputs:
- CreateSessionForm.razor: session name, worktree branch, worktree PR
- SessionListItem.razor: rename input
- SessionCard.razor: rename input

Adds InputSelectionTests.cs with convention tests to prevent regression.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant