From 1ff815fe5a622ec584430bae662f59116abd2675 Mon Sep 17 00:00:00 2001 From: Hale Rankin Date: Thu, 17 Sep 2020 09:40:02 -0700 Subject: [PATCH] 12360 Notebook UI - Mac/Win fix for Select all. (#12383) * 12360 Notebook UI - Mac/Win fix for Select all. * Fix for ctrl key selecting all in windows * Fix undo as well * preventDefault to prevent confusing behavior Co-authored-by: chlafreniere --- .../browser/cellViews/textCell.component.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/sql/workbench/contrib/notebook/browser/cellViews/textCell.component.ts b/src/sql/workbench/contrib/notebook/browser/cellViews/textCell.component.ts index 3860e416ea..e682319569 100644 --- a/src/sql/workbench/contrib/notebook/browser/cellViews/textCell.component.ts +++ b/src/sql/workbench/contrib/notebook/browser/cellViews/textCell.component.ts @@ -67,17 +67,18 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges { this.enableActiveCellEditOnDoubleClick(); } - @HostListener('document:keydown.meta.a', ['$event']) + @HostListener('document:keydown', ['$event']) onkeydown(e) { // use preventDefault() to avoid invoking the editor's select all // select the active . - e.preventDefault(); - document.execCommand('selectAll'); - } - - @HostListener('document:keydown.meta.z', ['$event']) - onUndo(e) { - document.execCommand('undo'); + if ((e.ctrlKey || e.metaKey) && e.key === 'a') { + e.preventDefault(); + document.execCommand('selectAll'); + } + if ((e.ctrlKey || e.metaKey) && e.key === 'z') { + e.preventDefault(); + document.execCommand('undo'); + } } private _content: string | string[];