From 81ae47f5885bfcfafc48486dace6e5813417e37d Mon Sep 17 00:00:00 2001 From: PrabinDevkota <123223087+PrabinDevkota@users.noreply.github.com> Date: Tue, 2 Jun 2026 02:31:03 +0530 Subject: [PATCH] Fix grid edit Enter on datetime fields triggering SQL modal When editing a datetime cell a second time, focus can be inside the datepicker widget instead of the text input. Enter was only handled on keyup for the input, so the key bubbled and submitted the SQL query form. Handle Enter on keydown for the input and for the cEdit container, and clean up datepicker/event state when closing the editor. Fixes #20323 Signed-off-by: Prabin Devkota --- resources/js/makegrid.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/resources/js/makegrid.ts b/resources/js/makegrid.ts index 028fa58bad..6debdc3e20 100644 --- a/resources/js/makegrid.ts +++ b/resources/js/makegrid.ts @@ -1191,7 +1191,10 @@ const makeGrid = function (t, enableResize = undefined, enableReorder = undefine firstDay: window.firstDayOfCalendar, }); - $inputField.on('keyup', function (e) { + $inputField.off('keydown.gridEditDateTime keyup.gridEditDateTime'); + $(g.cEdit).off('keydown.gridEditDateTime'); + + $inputField.on('keydown.gridEditDateTime', function (e) { if (e.which === 13) { // post on pressing "Enter" e.preventDefault(); @@ -1202,6 +1205,15 @@ const makeGrid = function (t, enableResize = undefined, enableReorder = undefine } }); + // Catch Enter when focus is in the datepicker UI (inside cEdit) + $(g.cEdit).on('keydown.gridEditDateTime', function (e) { + if (e.which === 13 && ! $(e.target).is('.edit_box')) { + e.preventDefault(); + e.stopPropagation(); + g.saveOrPostEditedCell(); + } + }); + $inputField.datepicker('show'); toggleDatepickerIfInvalid($td, $inputField);