Skip to content

fix(tui): check for selected text instead of any selection in dialog escape handler#16779

Open
altendky wants to merge 1 commit intoanomalyco:devfrom
altendky:fix/dialog-escape-selection
Open

fix(tui): check for selected text instead of any selection in dialog escape handler#16779
altendky wants to merge 1 commit intoanomalyco:devfrom
altendky:fix/dialog-escape-selection

Conversation

@altendky
Copy link
Contributor

@altendky altendky commented Mar 9, 2026

Issue for this PR

Closes #16778. May also fix #15202 and #14590.

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

PR #13315 added a selection guard to the dialog escape handler at dialog.tsx:73 that checks renderer.getSelection(). When clicking on selectable text (e.g. a user message), opentui creates a Selection object on mouseDown even for a simple click with no drag. This empty selection lingers after the dialog opens on mouseUp, so getSelection() returns a non-null object with no actual text — blocking Escape indefinitely.

One-line fix: renderer.getSelection()renderer.getSelection()?.getSelectedText(), so Escape is only blocked when there is actual selected text. This matches the existing pattern at:

How did you verify your code works?

Manually tested: opened Message Actions dialog by clicking a user message, pressed Escape — dialog now dismisses immediately without needing to click or type first.

Screenshots / recordings

No UI changes — keyboard behavior only.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

…escape handler

renderer.getSelection() returns a non-null Selection object from a simple
click on selectable text (no drag needed). This blocks Escape from dismissing
dialogs opened via mouse click. Use getSelectedText() to only block Escape
when there is actual text selected, matching the pattern already used in
session/index.tsx.
@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Mar 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant