From 105db4759f0255ebba4213f3f29d2d03032229cb Mon Sep 17 00:00:00 2001 From: Pavel Janda Date: Sun, 11 Jun 2017 13:18:45 +0200 Subject: [PATCH] InlineAdd: Right click on cancel button does not trigger the cancel event anymore, it is also triggered by left mouseup, not mousedown, closes #445 --- assets/src/datagrid.coffee | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/assets/src/datagrid.coffee b/assets/src/datagrid.coffee index 88984623..48dfed1f 100644 --- a/assets/src/datagrid.coffee +++ b/assets/src/datagrid.coffee @@ -589,11 +589,14 @@ $(document).on('click', '[data-datagrid-toggle-inline-add]', (e) -> row.find('input:not([readonly]),textarea:not([readonly])').first().focus() ) -$(document).on('mousedown', '[data-datagrid-cancel-inline-add]', (e) -> - e.stopPropagation() - e.preventDefault() +$(document).on('mouseup', '[data-datagrid-cancel-inline-add]', (e) -> + code = e.which || e.keyCode || 0 + + if code == 1 + e.stopPropagation() + e.preventDefault() - $('.datagrid-row-inline-add').addClass('datagrid-row-inline-add-hidden') + $('.datagrid-row-inline-add').addClass('datagrid-row-inline-add-hidden') ) $.nette.ext('datagrid-toggle-inline-add', {