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 <prabindev789@gmail.com>
This commit is contained in:
parent
2743a0a7ef
commit
81ae47f588
@ -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);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user