Skip to content

Dismiss popups and context menus with Escape#22

Merged
Robin-Reiche merged 2 commits into
Robin-Reiche:masterfrom
yukina3230:esc-dismiss-popups
Jun 19, 2026
Merged

Dismiss popups and context menus with Escape#22
Robin-Reiche merged 2 commits into
Robin-Reiche:masterfrom
yukina3230:esc-dismiss-popups

Conversation

@yukina3230

Copy link
Copy Markdown
Contributor

Adds a global Escape listener via closeAllPopups to dismiss context menus and popovers. It only intercepts when a popup is actually open, leaving Esc free to cancel cell edits otherwise.

@Robin-Reiche Robin-Reiche left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Nice, this is the cleanest of the three and I am happy to merge. I checked the AG Grid path: hidePopupMenu() is a real public GridApi method in 32.3.3 and it does close the filter popup. And since you only preventDefault and never stopPropagation, AG Grid's native Escape close still runs too, so the branch is correct and robust. Just one comment-clarity nit and a trailing newline, inline.

Comment thread src/webview/features/popups.ts Outdated

// Sets up a global Esc key listener to dismiss all popups (wired once at startup).
// - Uses the `capture phase` (true) to intercept the event before AG Grid consumes it.
// - Does NOT call `stopPropagation`, allowing individual popups to run their own cleanup logic (e.g., resetting state).

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Tiny clarity nit: this says individual popups run their own cleanup on Escape, but of the seven POPUP_IDS only rename and go-to-row have an Escape handler. Both are bound to their input element, so they only fire while that input has focus. For the context menus and dropdowns closeAllPopups() just toggles .hidden and nothing resets. Worth narrowing the comment to those two input-bound cases so a future reader does not assume Escape resets state for every popup.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Narrowed the comment, only rename and go-to-row have an input-bound Esc handler, the rest just hide.

Comment thread src/webview/features/popups.ts Outdated
closeAllPopups();
e.preventDefault();
}, true);
} No newline at end of file

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Nit: missing trailing newline at end of file (the diff shows 'No newline at end of file'). The other webview files end with one, so adding it back avoids a noisy diff later.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added the trailing newline back.

yukina3230 added a commit to yukina3230/csv-grid-editor that referenced this pull request Jun 18, 2026
@Robin-Reiche Robin-Reiche merged commit bde6c32 into Robin-Reiche:master Jun 19, 2026
1 check passed
Robin-Reiche added a commit that referenced this pull request Jun 19, 2026
@yukina3230 yukina3230 deleted the esc-dismiss-popups branch June 20, 2026 00:04
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.

2 participants