Skip to content

EspoCRM – Open Source CRM Application

shortcut fixes

Yuri Kuznetsov90c344a89c0c
diff --git a/client/modules/crm/src/views/calendar/calendar-page.js b/client/modules/crm/src/views/calendar/calendar-page.js
index 77b61f535e..fea74eea8a 100644
--- a/client/modules/crm/src/views/calendar/calendar-page.js
+++ b/client/modules/crm/src/views/calendar/calendar-page.js
@@ -32,6 +32,7 @@ import {inject} from 'di';
import ShortcutManager from 'helpers/site/shortcut-manager';
import DebounceHelper from 'helpers/util/debounce';
import WebSocketManager from 'web-socket-manager';
+import Utils from 'utils';
class CalendarPage extends View {
@@ -456,6 +457,10 @@ class CalendarPage extends View {
* @param {KeyboardEvent} e
*/
handleShortcutKeyHome(e) {
+ if (Utils.isKeyEventInTextInput(e)) {
+ return;
+ }
+
e.preventDefault();
this.getCalendarView().actionToday();
@@ -466,6 +471,17 @@ class CalendarPage extends View {
* @param {KeyboardEvent} e
*/
handleShortcutKeyArrowLeft(e) {
+ if (Utils.isKeyEventInTextInput(e)) {
+ return;
+ }
+
+ if (
+ e.target instanceof HTMLElement &&
+ e.target.parentElement instanceof HTMLLIElement
+ ) {
+ return;
+ }
+
e.preventDefault();
this.getCalendarView().actionPrevious();
@@ -476,6 +492,17 @@ class CalendarPage extends View {
* @param {KeyboardEvent} e
*/
handleShortcutKeyArrowRight(e) {
+ if (Utils.isKeyEventInTextInput(e)) {
+ return;
+ }
+
+ if (
+ e.target instanceof HTMLElement &&
+ e.target.parentElement instanceof HTMLLIElement
+ ) {
+ return;
+ }
+
e.preventDefault();
this.getCalendarView().actionNext();
@@ -486,6 +513,10 @@ class CalendarPage extends View {
* @param {KeyboardEvent} e
*/
handleShortcutKeyMinus(e) {
+ if (Utils.isKeyEventInTextInput(e)) {
+ return;
+ }
+
if (!this.getCalendarView().actionZoomOut) {
return;
}
@@ -500,6 +531,10 @@ class CalendarPage extends View {
* @param {KeyboardEvent} e
*/
handleShortcutKeyPlus(e) {
+ if (Utils.isKeyEventInTextInput(e)) {
+ return;
+ }
+
if (!this.getCalendarView().actionZoomIn) {
return;
}
@@ -515,6 +550,10 @@ class CalendarPage extends View {
* @param {Number} digit
*/
handleShortcutKeyDigit(e, digit) {
+ if (Utils.isKeyEventInTextInput(e)) {
+ return;
+ }
+
const modeList = this.getCalendarView().hasView('modeButtons') ?
this.getCalendarView()
.getModeButtonsView()
@@ -544,6 +583,10 @@ class CalendarPage extends View {
* @param {KeyboardEvent} e
*/
handleShortcutKeyControlSpace(e) {
+ if (Utils.isKeyEventInTextInput(e)) {
+ return;
+ }
+
if (!this.getCalendarView().createEvent) {
return;
}
diff --git a/client/src/utils.js b/client/src/utils.js
index 6de3c962ca..4fe93b9606 100644
--- a/client/src/utils.js
+++ b/client/src/utils.js
@@ -680,6 +680,40 @@ Espo.Utils = {
return key;
},
+ /**
+ * Check whether the pressed key is in a text input.
+ *
+ * @param {KeyboardEvent} e A key event.
+ * @return {boolean}
+ * @since 9.2.0
+ */
+ isKeyEventInTextInput: function (e) {
+ if (!(e.target instanceof HTMLElement)) {
+ return false;
+ }
+
+ if (e.target.tagName === 'TEXTAREA') {
+ return true;
+ }
+
+ if (e.target instanceof HTMLInputElement) {
+ if (
+ e.target.type === 'radio' ||
+ e.target.type === 'checkbox'
+ ) {
+ return false;
+ }
+
+ return true;
+ }
+
+ if (e.target.classList.contains('note-editable')) {
+ return true;
+ }
+
+ return false;
+ },
+
/**
* Generate an ID. Not to be used by 3rd party code.
*
diff --git a/client/src/views/email/detail.js b/client/src/views/email/detail.js
index 83e4869a65..e6b29fbf22 100644
--- a/client/src/views/email/detail.js
+++ b/client/src/views/email/detail.js
@@ -30,6 +30,7 @@ import DetailView from 'views/detail';
import EmailHelper from 'email-helper';
import RecordModal from 'helpers/record-modal';
import SelectOneAttachmentModalView from 'views/attachment/modals/select-one';
+import Utils from 'utils';
class EmailDetailView extends DetailView {
@@ -127,7 +128,7 @@ class EmailDetailView extends DetailView {
});
this.shortcutKeys['Control+Backspace'] = e => {
- if ($(e.target).hasClass('note-editable')) {
+ if (Utils.isKeyEventInTextInput(e)) {
return;
}
@@ -144,7 +145,7 @@ class EmailDetailView extends DetailView {
};
this.shortcutKeys['Control+Delete'] = e => {
- if ($(e.target).hasClass('note-editable')) {
+ if (Utils.isKeyEventInTextInput(e)) {
return;
}
@@ -161,7 +162,7 @@ class EmailDetailView extends DetailView {
};
this.shortcutKeys['Control+KeyI'] = e => {
- if ($(e.target).hasClass('note-editable')) {
+ if (Utils.isKeyEventInTextInput(e)) {
return;
}
@@ -180,7 +181,7 @@ class EmailDetailView extends DetailView {
};
this.shortcutKeys['Control+KeyM'] = e => {
- if ($(e.target).hasClass('note-editable')) {
+ if (Utils.isKeyEventInTextInput(e)) {
return;
}
diff --git a/client/src/views/email/list.js b/client/src/views/email/list.js
index feaaceb2b6..a89bf9149f 100644
--- a/client/src/views/email/list.js
+++ b/client/src/views/email/list.js
@@ -27,6 +27,7 @@
************************************************************************/
import ListView from 'views/list';
+import Utils from 'utils';
class EmailListView extends ListView {
@@ -337,6 +338,10 @@ class EmailListView extends ListView {
initEmailShortcuts() {
this.shortcutKeys['Control+Delete'] = e => {
+ if (Utils.isKeyEventInTextInput(e)) {
+ return;
+ }
+
if (!this.hasSelectedRecords()) {
return;
}
@@ -348,6 +353,10 @@ class EmailListView extends ListView {
};
this.shortcutKeys['Control+Backspace'] = e => {
+ if (Utils.isKeyEventInTextInput(e)) {
+ return;
+ }
+
if (!this.hasSelectedRecords()) {
return;
}
@@ -746,7 +755,7 @@ class EmailListView extends ListView {
* @param {KeyboardEvent} e
*/
handleShortcutKeyCtrlSpace(e) {
- if (e.target.tagName === 'TEXTAREA' || e.target.tagName === 'INPUT') {
+ if (Utils.isKeyEventInTextInput(e)) {
return;
}
diff --git a/client/src/views/list.js b/client/src/views/list.js
index eb12830698..32dee852c5 100644
--- a/client/src/views/list.js
+++ b/client/src/views/list.js
@@ -31,6 +31,7 @@
import MainView from 'views/main';
import SearchManager from 'search-manager';
import RecordModal from 'helpers/record-modal';
+import Utils from 'utils';
/**
* A list view.
@@ -881,10 +882,6 @@ class ListView extends MainView {
return;
}
- /*if (e.target.tagName === 'TEXTAREA' || e.target.tagName === 'INPUT') {
- return;
- }*/
-
if (!this.getAcl().checkScope(this.scope, 'create')) {
return;
}
@@ -948,21 +945,27 @@ class ListView extends MainView {
this.getSearchView().selectNextPreset();
}
- // noinspection JSUnusedLocalSymbols
/**
* @protected
* @param {KeyboardEvent} e
*/
handleShortcutKeyControlArrowLeft(e) {
+ if (Utils.isKeyEventInTextInput(e)) {
+ return;
+ }
+
this.getRecordView().trigger('request-page', 'previous');
}
- // noinspection JSUnusedLocalSymbols
/**
* @protected
* @param {KeyboardEvent} e
*/
handleShortcutKeyControlArrowRight(e) {
+ if (Utils.isKeyEventInTextInput(e)) {
+ return;
+ }
+
this.getRecordView().trigger('request-page', 'next');
}
diff --git a/client/src/views/modals/detail.js b/client/src/views/modals/detail.js
index ab8bd18257..097bbdcc91 100644
--- a/client/src/views/modals/detail.js
+++ b/client/src/views/modals/detail.js
@@ -32,6 +32,7 @@ import ModalView from 'views/modal';
import ActionItemSetup from 'helpers/action-item-setup';
import Backbone from 'backbone';
import RecordModal from 'helpers/record-modal';
+import Utils from 'utils';
/**
* A quick view modal.
@@ -67,7 +68,7 @@ class DetailModalView extends ModalView {
return;
}
- if (e.target.tagName === 'TEXTAREA' || e.target.tagName === 'INPUT') {
+ if (Utils.isKeyEventInTextInput(e)) {
return;
}
@@ -769,7 +770,7 @@ class DetailModalView extends ModalView {
return;
}
- if (e.target.tagName === 'TEXTAREA' || e.target.tagName === 'INPUT') {
+ if (Utils.isKeyEventInTextInput(e)) {
return;
}
@@ -792,7 +793,7 @@ class DetailModalView extends ModalView {
return;
}
- if (e.target.tagName === 'TEXTAREA' || e.target.tagName === 'INPUT') {
+ if (Utils.isKeyEventInTextInput(e)) {
return;
}
diff --git a/client/src/views/modals/related-list.js b/client/src/views/modals/related-list.js
index 01807ce19a..f539967360 100644
--- a/client/src/views/modals/related-list.js
+++ b/client/src/views/modals/related-list.js
@@ -33,6 +33,7 @@ import SearchManager from 'search-manager';
import $ from 'jquery';
import SelectRelatedHelper from 'helpers/record/select-related';
import CreateRelatedHelper from 'helpers/record/create-related';
+import Utils from 'utils';
/**
* A related-list modal.
@@ -71,12 +72,12 @@ class RelatedListModalView extends ModalView {
this.handleShortcutKeyCtrlPeriod(e);
},
/** @this RelatedListModalView */
- 'Control+ArrowLeft': function () {
- this.handleShortcutKeyControlArrowLeft();
+ 'Control+ArrowLeft': function (e) {
+ this.handleShortcutKeyControlArrowLeft(e);
},
/** @this RelatedListModalView */
- 'Control+ArrowRight': function () {
- this.handleShortcutKeyControlArrowRight();
+ 'Control+ArrowRight': function (e) {
+ this.handleShortcutKeyControlArrowRight(e);
},
}
@@ -704,15 +705,25 @@ class RelatedListModalView extends ModalView {
/**
* @protected
+ * @param {KeyboardEvent} e
*/
- handleShortcutKeyControlArrowLeft() {
+ handleShortcutKeyControlArrowLeft(e) {
+ if (Utils.isKeyEventInTextInput(e)) {
+ return;
+ }
+
this.getRecordView().trigger('request-page', 'previous');
}
/**
* @protected
+ * @param {KeyboardEvent} e
*/
- handleShortcutKeyControlArrowRight() {
+ handleShortcutKeyControlArrowRight(e) {
+ if (Utils.isKeyEventInTextInput(e)) {
+ return;
+ }
+
this.getRecordView().trigger('request-page', 'next');
}
}
diff --git a/client/src/views/record/detail.js b/client/src/views/record/detail.js
index df84ae46f8..4fa222ad1d 100644
--- a/client/src/views/record/detail.js
+++ b/client/src/views/record/detail.js
@@ -37,6 +37,7 @@ import DebounceHelper from 'helpers/util/debounce';
import {inject} from 'di';
import ShortcutManager from 'helpers/site/shortcut-manager';
import WebSocketManager from 'web-socket-manager';
+import Utils from 'utils';
/**
* A detail record view.
@@ -4093,7 +4094,7 @@ class DetailRecordView extends BaseRecordView {
return;
}
- if (e.target.tagName === 'TEXTAREA' || e.target.tagName === 'INPUT') {
+ if (Utils.isKeyEventInTextInput(e)) {
return;
}
@@ -4211,7 +4212,7 @@ class DetailRecordView extends BaseRecordView {
return;
}
- if (e.target.tagName === 'TEXTAREA' || e.target.tagName === 'INPUT') {
+ if (Utils.isKeyEventInTextInput(e)) {
return;
}
@@ -4244,7 +4245,7 @@ class DetailRecordView extends BaseRecordView {
return;
}
- if (e.target.tagName === 'TEXTAREA' || e.target.tagName === 'INPUT') {
+ if (Utils.isKeyEventInTextInput(e)) {
return;
}