Repository navigation
Stop Ctrl/Cmd+Enter adding a newline to a SQL field before a dialog saves it. #7167 - #10855
Conversation
…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
|
No actionable comments were generated in the recent review. WalkthroughThe 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. ChangesDialog save shortcut
Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Low Suggested reviewers: Merge Risk:
|
|
@coderabbitai review |
Action performed
|
Summary
Mod-Enterbinding (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.SchemaDialogViewnow marks its wrapper withdata-save-on-mod-enter, and the shared editor claimsMod-Enterwithout editing the text when it sits inside such an element. The keydown still bubbles to the dialog, which saves and closes as before.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
SchemaDialogViewKeyboard.spec.js: Ctrl+Enter in a dialog's SQL field saves the value unchanged and closes (fails without the fix).CodeMirrorCustomEditor.spec.js: Mod-Enter leaves the text alone inside a dialog (fails without the fix) and still inserts a blank line outside one.regression/javascript/{SchemaView,components,sqleditor}and eslint on changed files.Closes #7167
Summary by CodeRabbit