From b8332543aa40b0e01f99c73ab0462a5b702cbe9f Mon Sep 17 00:00:00 2001 From: daria Date: Tue, 1 Oct 2024 12:35:22 +0300 Subject: [PATCH 1/6] disable arrow key navigation in the drive while modal is active #1660 --- www/common/common-ui-elements.js | 7 +++---- www/common/drive-ui.js | 4 +++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index ae0dea302..b1a0e6a36 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -2510,13 +2510,11 @@ define([ } else { next(); } - return; - } - if (e.which === 13) { + } + else if (e.which === 13) { if ($container.find('.cp-icons-element-selected').length === 1) { $container.find('.cp-icons-element-selected').click(); } - return; } }); @@ -2525,6 +2523,7 @@ define([ window.setTimeout(function () { modal.show(); $modal.focus(); + next(); }); }; diff --git a/www/common/drive-ui.js b/www/common/drive-ui.js index 135b0eae0..28003d446 100644 --- a/www/common/drive-ui.js +++ b/www/common/drive-ui.js @@ -1045,7 +1045,9 @@ define([ // If the arrow keys aren't caught by another listener before, it means we can // use them to select content in the drive. If that's the case, we'll also // focus the drive container to avoid conflicts with other focused elements - $content.focus(); + if (!$('.cp-modal').is(':visible')) { + $content.focus(); + } var click = function (el) { if (!el) { return; } From b4292dcd851fbedcea3a251a1be1127763a045aa Mon Sep 17 00:00:00 2001 From: daria Date: Tue, 3 Dec 2024 12:04:43 +0200 Subject: [PATCH 2/6] disable arrow keys while a modal is opened #1660 --- www/common/drive-ui.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/www/common/drive-ui.js b/www/common/drive-ui.js index 28003d446..4b2d2b119 100644 --- a/www/common/drive-ui.js +++ b/www/common/drive-ui.js @@ -1045,9 +1045,7 @@ define([ // If the arrow keys aren't caught by another listener before, it means we can // use them to select content in the drive. If that's the case, we'll also // focus the drive container to avoid conflicts with other focused elements - if (!$('.cp-modal').is(':visible')) { - $content.focus(); - } + $content.focus(); var click = function (el) { if (!el) { return; } @@ -1062,6 +1060,11 @@ define([ $elements.index($selection.last()[0]); var length = $elements.length; if (length === 0) { return; } + + if ($('.cp-modal').is(':visible')) { + return; + } + // List mode if (getViewMode() === "list") { if (e.which === 40) { click($elements.get(Math.min(lastIndex+1, length -1))); } From 9b253eb98aafdab22eba922a06b0efcfa80d7b4f Mon Sep 17 00:00:00 2001 From: daria Date: Tue, 3 Dec 2024 12:14:49 +0200 Subject: [PATCH 3/6] fix arrow key bug --- www/common/drive-ui.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/www/common/drive-ui.js b/www/common/drive-ui.js index 4b2d2b119..16576ca58 100644 --- a/www/common/drive-ui.js +++ b/www/common/drive-ui.js @@ -990,6 +990,9 @@ define([ // Arrow keys to modify the selection var onWindowKeydown = function (e) { if (!$content.is(':visible')) { return; } + if ($('.cp-modal').is(':visible')) { + return; + } var $searchBar = $tree.find('#cp-app-drive-tree-search-input'); if (document.activeElement && document.activeElement.nodeName === 'INPUT') { return; } if ($searchBar.is(':focus') && $searchBar.val()) { return; } @@ -1061,10 +1064,6 @@ define([ var length = $elements.length; if (length === 0) { return; } - if ($('.cp-modal').is(':visible')) { - return; - } - // List mode if (getViewMode() === "list") { if (e.which === 40) { click($elements.get(Math.min(lastIndex+1, length -1))); } From 610414dc18a930a369a78da797cdd759dd3307ac Mon Sep 17 00:00:00 2001 From: daria Date: Wed, 4 Dec 2024 12:39:05 +0200 Subject: [PATCH 4/6] clean unnecessary changes --- www/common/common-ui-elements.js | 1 + www/common/drive-ui.js | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index b1a0e6a36..a2c3b709d 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -2514,6 +2514,7 @@ define([ else if (e.which === 13) { if ($container.find('.cp-icons-element-selected').length === 1) { $container.find('.cp-icons-element-selected').click(); + return; } } }); diff --git a/www/common/drive-ui.js b/www/common/drive-ui.js index 16576ca58..db2811fff 100644 --- a/www/common/drive-ui.js +++ b/www/common/drive-ui.js @@ -1063,7 +1063,6 @@ define([ $elements.index($selection.last()[0]); var length = $elements.length; if (length === 0) { return; } - // List mode if (getViewMode() === "list") { if (e.which === 40) { click($elements.get(Math.min(lastIndex+1, length -1))); } From 8262a0eb7bfaaf519a7bdcfbff0decabfbdd0a57 Mon Sep 17 00:00:00 2001 From: daria Date: Wed, 4 Dec 2024 12:59:51 +0200 Subject: [PATCH 5/6] clean unnecessary changes --- www/common/common-ui-elements.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index a2c3b709d..c615f3fba 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -2510,13 +2510,14 @@ define([ } else { next(); } + return; } - else if (e.which === 13) { + if (e.which === 13) { if ($container.find('.cp-icons-element-selected').length === 1) { $container.find('.cp-icons-element-selected').click(); - return; } } + return; }); From 6cc1908627a787eaff25c106e9c6fa1c2f4e0a4d Mon Sep 17 00:00:00 2001 From: daria Date: Wed, 4 Dec 2024 13:01:14 +0200 Subject: [PATCH 6/6] clean unnecessary changes --- www/common/common-ui-elements.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/common/common-ui-elements.js b/www/common/common-ui-elements.js index c615f3fba..f4c21b05c 100644 --- a/www/common/common-ui-elements.js +++ b/www/common/common-ui-elements.js @@ -2511,13 +2511,13 @@ define([ next(); } return; - } + } if (e.which === 13) { if ($container.find('.cp-icons-element-selected').length === 1) { $container.find('.cp-icons-element-selected').click(); } + return; } - return; });