Skip to content

Keyboard shortcut improvements: tab switching, editor duplicate-line, dialog Enter/Escape#10067

Open
dpage wants to merge 1 commit into
pgadmin-org:masterfrom
dpage:feature/keyboard-shortcut-improvements
Open

Keyboard shortcut improvements: tab switching, editor duplicate-line, dialog Enter/Escape#10067
dpage wants to merge 1 commit into
pgadmin-org:masterfrom
dpage:feature/keyboard-shortcut-improvements

Conversation

@dpage

@dpage dpage commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

A cluster of keyboard-shortcut improvements across the workspace tabs, the SQL
editor, and dialogs.

Main tab switching (#7232)

The "Tabbed panel forward/backward" shortcut did nothing when keyboard focus
was inside a tool (SQL editor, PSQL terminal, ERD/Schema Diff canvas), because
bindRightPanel resolved the target tab from document.activeElement, which
pointed at the tool's own nested dock tab rather than a workspace tab. It now
locates the active workspace tab via rc-dock's dock-tab-active class
(independent of focus) and restricts cycling to the workspace tab-set.

The default was also colliding with the Query Tool's inner-panel navigation
(both were Alt+Shift+] / [) and emitted typographic glyphs on macOS. The
default is changed to Ctrl/Cmd+Alt+] / [ (inner-panel nav keeps
Alt+Shift+] / [, unchanged), and the bogus key codes (Meta / ContextMenu —
the latter literally triggered the browser's "display a menu") are corrected to
the real bracket key codes.

SQL editor (#3834)

Add Ctrl/Cmd+Shift+D to duplicate the current line or selection.

Dialogs (#7167, #5691, #5196)

Object/utility dialogs rendered as dockable panels (Properties, Backup, the
Query Tool sort/filter dialog, etc.) gain:

The Escape handler is scoped to panel dialogs (MUI modals already close on
Escape) and yields to inner controls that handle Escape first (e.g. an open
dropdown). This also makes the unsaved-changes confirmation operable from the
keyboard (#5196) without explicit per-button letter shortcuts.

Test plan

Verified interactively in a desktop-mode instance:

  • Tab switch works with focus in the SQL editor / PSQL / ERD / Schema Diff, cycling only the workspace tabs.
  • Ctrl/Cmd+Shift+D duplicates the current line/selection.
  • Ctrl/Cmd+Enter saves a dialog; Escape closes Properties/Backup dialogs (and modals still close once, dropdowns close first).

Default shortcuts and the new editor shortcut are documented in
keyboard_shortcuts.rst.

Closes #7232
Closes #3834
Closes #7167
Closes #5691
Closes #5196

Summary by CodeRabbit

Release Notes

  • New Features

    • Added keyboard shortcut to duplicate lines in SQL editor (Ctrl+Shift+d / Cmd+Shift+d)
    • Added keyboard shortcuts for dialog operations: save with Ctrl/Cmd+Enter, close with Escape
  • Bug Fixes

    • Fixed keyboard focus handling in tabbed panels with nested layouts
  • Documentation

    • Updated keyboard shortcuts documentation and v9.16 release notes with new shortcuts and navigation improvements

- Fix the main "tabbed panel forward/backward" shortcut not switching the
  workspace tabs when keyboard focus is inside a tool (SQL editor, PSQL
  terminal, ERD or Schema Diff). bindRightPanel now locates the active
  workspace tab via rc-dock's dock-tab-active class, independent of focus,
  and restricts cycling to the workspace tab-set. The default shortcut is
  changed to Ctrl/Cmd+Alt+] / [ so it no longer collides with the Query
  Tool's inner-panel navigation (Alt+Shift+] / [) and does not emit glyphs
  on macOS; the bogus key codes (Meta/ContextMenu) are corrected to the
  bracket key codes.
- Add Ctrl/Cmd+Shift+D to duplicate the current line or selection in the
  SQL editor.
- Add Ctrl/Cmd+Enter to save and close object/utility dialogs (including the
  Query Tool sort/filter dialog), and Escape to close them - dialogs rendered
  as dockable panels (Properties, Backup, etc.) previously had neither. The
  Escape handler is scoped to panel dialogs (skips MUI modals, which already
  close on Escape) and yields to inner controls that handle Escape first.

Closes pgadmin-org#7232
Closes pgadmin-org#3834
Closes pgadmin-org#7167
Closes pgadmin-org#5691
Closes pgadmin-org#5196
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0eafc04d-2f60-43d9-8780-fe0a732a3aa0

📥 Commits

Reviewing files that changed from the base of the PR and between 04fa05c and 6daf896.

📒 Files selected for processing (6)
  • docs/en_US/keyboard_shortcuts.rst
  • docs/en_US/release_notes_9_16.rst
  • web/pgadmin/browser/register_browser_preferences.py
  • web/pgadmin/browser/static/js/keyboard.js
  • web/pgadmin/static/js/SchemaView/SchemaDialogView.jsx
  • web/pgadmin/static/js/components/ReactCodeMirror/components/Editor.jsx

Walkthrough

This PR enhances pgAdmin's keyboard shortcut system across three areas: it fixes tabbed panel navigation to work reliably when keyboard focus is inside nested tools, adds Ctrl/Cmd+Enter and Escape shortcuts to dialogs for save/close actions, and adds Mod+Shift+d to the CodeMirror editor for line duplication.

Changes

Keyboard Shortcuts Enhancement

Layer / File(s) Summary
Tabbed Panel Navigation Fix
web/pgadmin/browser/register_browser_preferences.py, web/pgadmin/browser/static/js/keyboard.js, docs/en_US/keyboard_shortcuts.rst, docs/en_US/release_notes_9_16.rst
Tab navigation refactored to find the active dock-tab element by querying #root rather than relying on document.activeElement, making it work reliably when focus is inside nested tools like Query Tool or PSQL. Shortcut modifiers changed from Shift+Alt to Ctrl+Alt on Windows/Linux (Ctrl+Option on Mac) to avoid collisions with inner-panel shortcuts.
Dialog Keyboard Shortcuts
web/pgadmin/static/js/SchemaView/SchemaDialogView.jsx, docs/en_US/release_notes_9_16.rst
Dialog container now handles Ctrl/Cmd+Enter to save and close, and Escape to close. Event handlers guard against nested dialogs and already-handled events to prevent unintended behavior.
Code Editor Line Duplication
web/pgadmin/static/js/components/ReactCodeMirror/components/Editor.jsx, docs/en_US/keyboard_shortcuts.rst
CodeMirror keymap extended with Mod+Shift+d binding to trigger copyLineDown, enabling line/selection duplication within the SQL editor.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title accurately summarizes all three main changes: tab switching fix, editor duplicate-line shortcut, and dialog Enter/Escape support.
Linked Issues check ✅ Passed All code changes directly address requirements from linked issues: tab switching fix (#7232), duplicate-line shortcut (#3834), and dialog keyboard shortcuts (#7167, #5691, #5196).
Out of Scope Changes check ✅ Passed All changes align with stated PR objectives. Documentation updates to keyboard_shortcuts.rst and release notes are appropriate supporting changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR improves keyboard navigation across pgAdmin’s main workspace tabs, SQL editor (CodeMirror), and SchemaView-based dialogs, and updates documentation/release notes accordingly.

Changes:

  • Fixes main tab switching shortcuts so they work even when focus is inside nested tools/iframes, and restricts cycling to the workspace tab-set.
  • Adds SQL editor shortcut Mod+Shift+D to duplicate the current line/selection.
  • Adds dialog/panel shortcuts: Ctrl/Cmd+Enter to trigger Save, and Escape to Close (for dockable panel dialogs).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
web/pgadmin/static/js/SchemaView/SchemaDialogView.jsx Add keydown handling for Ctrl/Cmd+Enter (save) and Escape (close) in SchemaView dialogs.
web/pgadmin/static/js/components/ReactCodeMirror/components/Editor.jsx Add CodeMirror keybinding for duplicating current line/selection.
web/pgadmin/browser/static/js/keyboard.js Improve main workspace tab switching by finding the active workspace tab independent of focus and limiting cycling to the active tab-set.
web/pgadmin/browser/register_browser_preferences.py Update default tab-switch shortcuts and correct bracket key codes.
docs/en_US/release_notes_9_16.rst Document the new shortcuts and the tab-switch fix in 9.16 release notes.
docs/en_US/keyboard_shortcuts.rst Update shortcut documentation for new defaults and editor duplicate-line shortcut.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +181 to +183
// Ctrl/Cmd+Enter saves and closes the dialog from anywhere within it
// (issue #7167). onSaveClick is a no-op when there is nothing to save or
// there is a validation error, so this is safe to call unconditionally.
*********

| `Issue #6308 <https://github.com/pgadmin-org/pgadmin4/issues/6308>`_ - Fix the infinite loading spinner after an idle database connection is silently dropped, by detecting stale connections and offering a reconnect dialog.
| `Issue #7232 <https://github.com/pgadmin-org/pgadmin4/issues/7232>`_ - Fix the tabbed panel forward/backward shortcut not switching the main tabs when keyboard focus is inside a tool (SQL editor, PSQL terminal, ERD or Schema Diff). The default shortcut is now Ctrl/Cmd+Alt+] / [ to avoid colliding with the Query Tool's inner-panel navigation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment