This is an automated email from the ASF dual-hosted git repository. mcgilman pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/main by this push: new a840c14c84 [NIFI-13158] - Fix: need to prevent/diable keyboard hotkeys when a dialog is open or when typeing in the search bar. (#8781) a840c14c84 is described below commit a840c14c8410fe11d4e71499e758195623b24053 Author: Rob Fellows <rob.fell...@gmail.com> AuthorDate: Wed May 8 18:45:23 2024 -0400 [NIFI-13158] - Fix: need to prevent/diable keyboard hotkeys when a dialog is open or when typeing in the search bar. (#8781) This closes #8781 --- .../flow-designer/ui/canvas/canvas.component.ts | 63 ++++++++++++++-------- 1 file changed, 41 insertions(+), 22 deletions(-) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/canvas.component.ts b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/canvas.component.ts index 9dbaa4a28a..b38327ffa6 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/canvas.component.ts +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-frontend/src/main/nifi/src/app/pages/flow-designer/ui/canvas/canvas.component.ts @@ -68,6 +68,7 @@ import { selectUrl } from '../../../../state/router/router.selectors'; import { Storage } from '../../../../service/storage.service'; import { CanvasUtils } from '../../service/canvas-utils.service'; import { CanvasActionsService } from '../../service/canvas-actions.service'; +import { MatDialog } from '@angular/material/dialog'; @Component({ selector: 'fd-canvas', @@ -87,7 +88,8 @@ export class Canvas implements OnInit, OnDestroy { private storage: Storage, private canvasUtils: CanvasUtils, public canvasContextMenu: CanvasContextMenu, - private canvasActionsService: CanvasActionsService + private canvasActionsService: CanvasActionsService, + private dialog: MatDialog ) { this.store .select(selectTransform) @@ -596,80 +598,97 @@ export class Canvas implements OnInit, OnDestroy { this.store.dispatch(stopProcessGroupPolling()); } - private executeAction(actionId: string, bypassCondition?: boolean): boolean { - const selection = this.canvasUtils.getSelection(); - const canvasAction = this.canvasActionsService.getAction(actionId); - if (canvasAction) { - if (bypassCondition || canvasAction.condition(selection)) { - canvasAction.action(selection); - return true; + private processKeyboardEvents(event: KeyboardEvent): boolean { + const source = event.target as any; + let searchFieldIsEventSource = false; + if (source) { + searchFieldIsEventSource = source.classList.contains('search-input') || false; + } + + return this.dialog.openDialogs.length === 0 && !searchFieldIsEventSource; + } + + private executeAction(actionId: string, event: KeyboardEvent, bypassCondition?: boolean): boolean { + if (this.processKeyboardEvents(event)) { + const selection = this.canvasUtils.getSelection(); + const canvasAction = this.canvasActionsService.getAction(actionId); + if (canvasAction) { + if (bypassCondition || canvasAction.condition(selection)) { + canvasAction.action(selection); + return true; + } } } return false; } @HostListener('window:keydown.delete', ['$event']) - handleKeyDownDelete() { - this.executeAction('delete'); + handleKeyDownDelete(event: KeyboardEvent) { + this.executeAction('delete', event); } + @HostListener('window:keydown.backspace', ['$event']) - handleKeyDownBackspace() { - this.executeAction('delete'); + handleKeyDownBackspace(event: KeyboardEvent) { + this.executeAction('delete', event); } @HostListener('window:keydown.control.r', ['$event']) handleKeyDownCtrlR(event: KeyboardEvent) { - if (this.executeAction('refresh', true)) { + if (this.executeAction('refresh', event, true)) { event.preventDefault(); } } + @HostListener('window:keydown.meta.r', ['$event']) handleKeyDownMetaR(event: KeyboardEvent) { - if (this.executeAction('refresh', true)) { + if (this.executeAction('refresh', event, true)) { event.preventDefault(); } } @HostListener('window:keydown.escape', ['$event']) - handleKeyDownEsc() { - this.executeAction('leaveGroup'); + handleKeyDownEsc(event: KeyboardEvent) { + this.executeAction('leaveGroup', event); } @HostListener('window:keydown.control.c', ['$event']) handleKeyDownCtrlC(event: KeyboardEvent) { - if (this.executeAction('copy')) { + if (this.executeAction('copy', event)) { event.preventDefault(); } } + @HostListener('window:keydown.meta.c', ['$event']) handleKeyDownMetaC(event: KeyboardEvent) { - if (this.executeAction('copy')) { + if (this.executeAction('copy', event)) { event.preventDefault(); } } @HostListener('window:keydown.control.v', ['$event']) handleKeyDownCtrlV(event: KeyboardEvent) { - if (this.executeAction('paste')) { + if (this.executeAction('paste', event)) { event.preventDefault(); } } + @HostListener('window:keydown.meta.v', ['$event']) handleKeyDownMetaV(event: KeyboardEvent) { - if (this.executeAction('paste')) { + if (this.executeAction('paste', event)) { event.preventDefault(); } } @HostListener('window:keydown.control.a', ['$event']) handleKeyDownCtrlA(event: KeyboardEvent) { - if (this.executeAction('selectAll')) { + if (this.executeAction('selectAll', event)) { event.preventDefault(); } } + @HostListener('window:keydown.meta.a', ['$event']) handleKeyDownMetaA(event: KeyboardEvent) { - if (this.executeAction('selectAll')) { + if (this.executeAction('selectAll', event)) { event.preventDefault(); } }