Skip to content

Commit 78aea4d

Browse files
authored
Fix WASD navigation in IFC viewer (#9722)
When the IFC was focussed and the S key was pressed, the global search input was opened and further key inputs went into the search field instead of the expected zooming out in the viewer.
1 parent 93533d9 commit 78aea4d

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

frontend/src/app/modules/a11y/keyboard-shortcut-service.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,15 @@ export class KeyboardShortcutService {
9191

9292
public accessKey(keyName:'preview'|'newWorkPackage'|'edit'|'quickSearch'|'projectSearch'|'help'|'moreMenu'|'details') {
9393
var key = accessKeys[keyName];
94+
9495
return () => {
96+
// Guard: When the focus is on the IFC viewer, pressing the key "S" shall control the viewer as part of its
97+
// WASD navigation. So dismiss that shortcuts and let the event pass on to the IFC viewer.
98+
if (key === 4 &&
99+
document.activeElement?.getAttribute('data-qa-selector') === 'op-ifc-viewer--model-canvas') {
100+
return;
101+
}
102+
95103
var elem = jQuery('[accesskey=' + key + ']:first');
96104
if (elem.is('input') || elem.attr('id') === 'global-search-input') {
97105
// timeout with delay so that the key is not

frontend/src/app/modules/bim/ifc_models/ifc-viewer/ifc-viewer.component.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ export class IFCViewerComponent implements OnInit, OnDestroy {
7272
constructor(private I18n:I18nService,
7373
private elementRef:ElementRef,
7474
public ifcData:IfcModelsDataService,
75-
private ifcViewer:IFCViewerService,
75+
private ifcViewerService:IFCViewerService,
7676
private currentUserService:CurrentUserService,
7777
private currentProjectService:CurrentProjectService) {
78-
this.inspectorVisible$ = this.ifcViewer.inspectorVisible$;
78+
this.inspectorVisible$ = this.ifcViewerService.inspectorVisible$;
7979
}
8080

8181
ngOnInit():void {
@@ -97,9 +97,9 @@ export class IFCViewerComponent implements OnInit, OnDestroy {
9797
this.currentProjectService.id as string,
9898
)
9999
.subscribe((manageIfcModelsAllowed) => {
100-
this.ifcViewer.newViewer(
100+
this.ifcViewerService.newViewer(
101101
{
102-
canvasElement: element.find('[data-qa-selector="op-ifc-viewer--model-canvas"]')[0], // WebGL canvas
102+
canvasElement: this.modelCanvas.nativeElement, // WebGL canvas
103103
explorerElement: jQuery('.op-ifc-viewer--tree-panel')[0], // Left panel
104104
toolbarElement: element.find('[data-qa-selector="op-ifc-viewer--toolbar-container"]')[0], // Toolbar
105105
inspectorElement: element.find('[data-qa-selector="op-ifc-viewer--inspector-container"]')[0], // Toolbar
@@ -110,29 +110,30 @@ export class IFCViewerComponent implements OnInit, OnDestroy {
110110
this.ifcData.projects,
111111
);
112112
});
113+
113114
}
114115

115116
ngOnDestroy():void {
116-
this.ifcViewer.destroy();
117+
this.ifcViewerService.destroy();
117118
}
118119

119120
toggleInspector() {
120-
this.ifcViewer.inspectorVisible$.next(!this.inspectorVisible$.getValue());
121+
this.ifcViewerService.inspectorVisible$.next(!this.inspectorVisible$.getValue());
121122
}
122123

123124
@HostListener('mousedown')
124125
enableKeyBoard() {
125126
if (this.modelCount) {
126127
this.keyboardEnabled = true;
127-
this.ifcViewer.setKeyboardEnabled(true);
128+
this.ifcViewerService.setKeyboardEnabled(true);
128129
}
129130
}
130131

131132
@HostListener('window:mousedown', ['$event.target'])
132133
disableKeyboard(target:Element) {
133-
if (this.modelCount && !this.outerContainer.nativeElement!.contains(target)) {
134+
if (this.modelCount && !this.outerContainer.nativeElement?.contains(target)) {
134135
this.keyboardEnabled = false;
135-
this.ifcViewer.setKeyboardEnabled(false);
136+
this.ifcViewerService.setKeyboardEnabled(false);
136137
}
137138
}
138139

0 commit comments

Comments
 (0)