prevent children events from bubbling up (#7040)

This commit is contained in:
Cilibiu Bogdan
2021-05-18 16:04:10 +03:00
committed by GitHub
parent 2335143546
commit f03d133899
2 changed files with 21 additions and 2 deletions

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Component, ContentChildren, EventEmitter, Input, Output, QueryList, TemplateRef, ViewChild, ViewEncapsulation } from '@angular/core';
import { Component, ContentChildren, EventEmitter, HostListener, Input, Output, QueryList, TemplateRef, ViewChild, ViewEncapsulation } from '@angular/core';
import { MatTabChangeEvent } from '@angular/material/tabs';
@Component({
selector: 'adf-info-drawer-tab',
@@ -61,6 +61,16 @@ export class InfoDrawerComponent {
@ContentChildren(InfoDrawerTabComponent)
contentBlocks: QueryList<InfoDrawerTabComponent>;
@HostListener('keydown', ['$event'])
onKeyDown(event: KeyboardEvent) {
event.cancelBubble = true;
}
@HostListener('keyup', ['$event'])
onKeyUp(event: KeyboardEvent) {
event.cancelBubble = true;
}
showTabLayout(): boolean {
return this.contentBlocks.length > 0;
}

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { ChangeDetectionStrategy, Component, ViewEncapsulation } from '@angular/core';
import { ChangeDetectionStrategy, Component, HostListener, ViewEncapsulation } from '@angular/core';
@Component({
selector: 'adf-viewer-sidebar',
@@ -25,4 +25,13 @@ import { ChangeDetectionStrategy, Component, ViewEncapsulation } from '@angular/
template: `<ng-content></ng-content>`
})
export class ViewerSidebarComponent {
@HostListener('keydown', ['$event'])
onKeyDown(event: KeyboardEvent) {
event.cancelBubble = true;
}
@HostListener('keyup', ['$event'])
onKeyUp(event: KeyboardEvent) {
event.cancelBubble = true;
}
}