Skip to content

Stop Ctrl/Cmd+Enter adding a newline to a SQL field before a dialog saves it. #7167 - #10855

Merged
dpage merged 1 commit into
pgadmin-org:masterfrom
dpage:fix/issue-7167-mod-enter-newline
Nov 27, 2026
Merged

dpage merged 1 commit into
pgadmin-org:masterfrom
dpage:fix/issue-7167-mod-enter-newline

Conversation

@dpage

@dpage dpage commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • With focus in a SQL editor field of a dialog (the Sort/Filter SQL Filter, a function's Code, and so on), Ctrl/Cmd+Enter ran CodeMirror's default Mod-Enter binding (insertBlankLine) before the dialog's save handler, so the newline was saved: an empty Sort/Filter failed with "syntax error at end of input", and function bodies gained a trailing newline.
  • SchemaDialogView now marks its wrapper with data-save-on-mod-enter, and the shared editor claims Mod-Enter without editing the text when it sits inside such an element. The keydown still bubbles to the dialog, which saves and closes as before.
  • Editors outside a dialog, such as the Query Tool's, keep the existing behaviour; the new binding sits after the Query Tool's own shortcut keymap, so a user-configured Ctrl+Enter shortcut there still wins.

The other point in the reopening comment (the shortcut submitting an unchanged Sort/Filter whilst its Save button is disabled, since 'create' mode always has changes) is left for a separate change.

Test plan

  • New Jest test in SchemaDialogViewKeyboard.spec.js: Ctrl+Enter in a dialog's SQL field saves the value unchanged and closes (fails without the fix).
  • New tests in CodeMirrorCustomEditor.spec.js: Mod-Enter leaves the text alone inside a dialog (fails without the fix) and still inserts a blank line outside one.
  • Jest for regression/javascript/{SchemaView,components,sqleditor} and eslint on changed files.

Closes #7167

Summary by CodeRabbit

  • Bug Fixes
    • Ctrl/Cmd+Enter in a schema dialog’s SQL editor now saves and closes the dialog without inserting a newline.
    • Ctrl/Cmd+Enter continues to insert a newline in editors outside the dialog.

…aves it. pgadmin-org#7167

The shared CodeMirror editor kept the default Mod-Enter binding
(insertBlankLine), so with focus in a SQL field of a dialog the newline
was inserted before the dialog's Ctrl/Cmd+Enter handler saved, and was
saved with the value. The dialog now marks itself with
data-save-on-mod-enter and the editor claims Mod-Enter, without editing
the text, when it sits inside such an element. Editors elsewhere, such
as the Query Tool's, are unaffected.

Closes pgadmin-org#7167
@dpage dpage self-assigned this Nov 26, 2026
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The schema dialog marks its container for save-shortcut handling. The CodeMirror keymap handles Mod-Enter inside marked containers without inserting a newline. Tests cover the dialog save flow and default newline behavior outside a marked container.

Changes

Dialog save shortcut

Layer / File(s) Summary
Dialog save shortcut handling
web/pgadmin/static/js/SchemaView/SchemaDialogView.jsx, web/pgadmin/static/js/components/ReactCodeMirror/components/Editor.jsx, web/regression/javascript/SchemaView/SchemaDialogViewKeyboard.spec.js, web/regression/javascript/components/CodeMirrorCustomEditor.spec.js
The schema dialog adds data-save-on-mod-enter. The editor handles Mod-Enter within marked containers and leaves it unhandled elsewhere. Tests check saving the unchanged SQL value and newline behavior inside and outside a marked container.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: pravesh-sharma, rohitbhati8269

Merge Risk: Minimal · up to 96e45

Ctrl/Cmd+Enter in SQL fields inside dialogs no longer inserts a newline before the dialog saves. Editors outside dialogs, including the Query Tool, keep their existing behavior. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main behavior change: Ctrl/Cmd+Enter no longer adds a newline to a SQL field before a dialog saves. The changeset adds data-save-on-mod-enter to SchemaDialogView and makes the shar…
Linked Issues check Passed Directly linked issue #7167 asks for Ctrl+Enter (Cmd+Enter on macOS) to save and close the Sort/Filter dialog. The PR addresses this in the shared CodeMirror editor (web/pgadmin/static/js/components/R…
Out of Scope Changes check Passed All changed files relate to the linked objective. Editor.jsx adds the scoped Mod-Enter handling. SchemaDialogView.jsx adds the marker attribute and its comment. The two spec files add tests for the ne…
Full details: Title check

Explanation

The title names the main behavior change: Ctrl/Cmd+Enter no longer adds a newline to a SQL field before a dialog saves. The changeset adds data-save-on-mod-enter to SchemaDialogView and makes the shared CodeMirror Editor skip newline insertion for Mod-Enter inside such a wrapper, with matching tests. The title is specific and on topic. It does not mention the linked issue's save-and-close goal, but it is not misleading.

Full details: Linked Issues check

Explanation

Directly linked issue #7167 asks for Ctrl+Enter (Cmd+Enter on macOS) to save and close the Sort/Filter dialog. The PR addresses this in the shared CodeMirror editor (web/pgadmin/static/js/components/ReactCodeMirror/components/Editor.jsx). The editor claims Mod-Enter without inserting a newline when it sits inside an element marked data-save-on-mod-enter. SchemaDialogView.jsx adds that marker to its StyledBox. The keydown then bubbles to the existing dialog save handler, which saves and closes. The new SchemaDialogViewKeyboard.spec.js test covers Ctrl+Enter in a dialog SQL field: the value stays unchanged, onSave receives it, and the dialog closes. The new CodeMirrorCustomEditor.spec.js tests cover the inside-dialog and outside-dialog cases. The issue's general request for other dialogs is met by the marker mechanism, which any SchemaDialogView dialog inherits. The unchanged-value submission while Save is disabled is a separate follow-up that the PR states it does not cover. Evidence basis: the PR summary, the PR description, and the AI-generated change summaries. The repository diff could not be read because changed blobs were unavailable, so the code-level behavior rests on these summaries and the described tests.

Full details: Out of Scope Changes check

Explanation

All changed files relate to the linked objective. Editor.jsx adds the scoped Mod-Enter handling. SchemaDialogView.jsx adds the marker attribute and its comment. The two spec files add tests for the new behavior. The keymap is placed after the Query Tool's shortcut keymap, so Query Tool behavior is kept, as the PR describes. No unrelated changes are described in the summary. Evidence basis: the summaries and PR description. The repository diff could not be read, so this verdict does not rely on a line-level review of the changes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 3b6b9b2 and 96e4537.

Files selected for processing: 4

  • web/pgadmin/static/js/SchemaView/SchemaDialogView.jsx
  • web/pgadmin/static/js/components/ReactCodeMirror/components/Editor.jsx
  • web/regression/javascript/SchemaView/SchemaDialogViewKeyboard.spec.js
  • web/regression/javascript/components/CodeMirrorCustomEditor.spec.js

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 0 remain after this review.

@dpage

dpage commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@dpage
dpage merged commit 0080da2 into pgadmin-org:master Nov 27, 2026
17 checks passed
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.

Please add a keyboard shortcut (Ctrl + Enter) for saving and closing the sort/filter dialog

1 participant