Merge pull request #6461 from opf/fix/27789/dont-stop-propagation-acessible-click

[27789] Don't prevent default on all accessible clicks

[ci skip]
pull/6463/head
Oliver Günther 6 years ago committed by GitHub
commit 65896cf32a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      frontend/src/app/components/op-context-menu/op-context-menu.html
  2. 6
      frontend/src/app/modules/a11y/accessible-click.directive.ts

@ -13,7 +13,8 @@
[attr.href]="item.href || ''"
[attr.aria-disabled]="item.disabled"
[attr.aria-label]="item.ariaLabel || item.linkText"
(accessibleClick)="handleClick(item, $event)">
(accessibleClick)="handleClick(item, $event)"
[accessibleClickStopEvent]="false">
<op-icon *ngIf="item.icon" icon-classes="icon-action-menu {{ item.icon }}"> </op-icon>
<span [textContent]="item.linkText"></span>
</a>

@ -26,21 +26,25 @@
// See doc/COPYRIGHT.rdoc for more details.
//++
import {Directive, EventEmitter, HostListener, Output} from '@angular/core';
import {Directive, EventEmitter, HostListener, Input, Output} from '@angular/core';
import {keyCodes} from 'core-app/modules/common/keyCodes.enum';
@Directive({
selector: '[accessibleClick]',
})
export class AccessibleClickDirective {
@Input('accessibleClickStopEvent') stopEventPropagation:boolean = true;
@Output('accessibleClick') onClick = new EventEmitter<JQueryEventObject>();
@HostListener('click', ['$event'])
@HostListener('keydown', ['$event'])
public handleClick(event:JQueryEventObject) {
if (event.type === 'click' || event.which === keyCodes.ENTER || event.which === keyCodes.SPACE) {
if (this.stopEventPropagation) {
event.preventDefault();
event.stopPropagation();
}
this.onClick.emit(event);
}

Loading…
Cancel
Save