From 08999d74d893dae3bc6c1384adbcd25328047d93 Mon Sep 17 00:00:00 2001 From: Aditya Bist Date: Thu, 23 Jul 2020 11:58:20 -0700 Subject: [PATCH] fix keyevents for results --- .../src/js/components/app.component.ts | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/views/htmlcontent/src/js/components/app.component.ts b/src/views/htmlcontent/src/js/components/app.component.ts index deb9d6816c..8f6c8e27d7 100644 --- a/src/views/htmlcontent/src/js/components/app.component.ts +++ b/src/views/htmlcontent/src/js/components/app.component.ts @@ -796,22 +796,30 @@ export class AppComponent implements OnInit, AfterViewChecked { * */ async keyEvent(e: any): Promise { - if (e.target.classList.contains('slick-cell')) { + // set selection to none for messages so that ctrl + A + // only selects the results grid + const isGridSelection: boolean = e.target.classList.contains('slick-cell'); + if (isGridSelection) { $('#messages').css('user-select', 'none'); - let eString = this.shortcuts.buildEventString(e); - let result = await this.shortcuts.getEvent(eString); - if (result) { - let eventName = result; - this.shortcutfunc[eventName](); - if (eventName === 'event.selectAll') { - window.getSelection().empty(); - rangy.getSelection().removeAllRanges(); - } - e.stopImmediatePropagation(); - } } else { + // otherwise make the messages selectable $('#messages').css('user-select', 'text'); } + let eString = this.shortcuts.buildEventString(e); + let result = await this.shortcuts.getEvent(eString); + if (result) { + let eventName = result; + // Don't select all the grid if it's not grid selection + // otherwise run every shortcut function + if (!(eventName === 'event.selectAll' && !isGridSelection)) { + this.shortcutfunc[eventName](); + } + if (eventName === 'event.selectAll') { + window.getSelection().empty(); + rangy.getSelection().removeAllRanges(); + } + e.stopImmediatePropagation(); + } } /**