MOBILE-3320 core: Fix supress events usage on send message form

main
Pau Ferrer Ocaña 2021-05-26 11:13:32 +02:00
parent fa67fbef81
commit 877c79ed5a
2 changed files with 11 additions and 1 deletions

View File

@ -17,7 +17,7 @@
>
</textarea>
<ion-button fill="clear" size="large" type="submit" [disabled]="!message || sendDisabled"
[attr.aria-label]="'core.send' | translate" [core-suppress-events] (click)="submitForm($event)">
[attr.aria-label]="'core.send' | translate" [core-suppress-events] (onClick)="submitForm($event)">
<ion-icon name="send" color="dark" slot="icon-only" aria-hidden="true"></ion-icon>
</ion-button>
</form>

View File

@ -15,6 +15,7 @@
// Based on http://roblouie.com/article/198/using-gestures-in-the-ionic-2-beta/
import { Directive, ElementRef, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { CoreLogger } from '@singletons/logger';
/**
* Directive to suppress all events on an element. This is useful to prevent keyboard closing when clicking this element.
@ -29,6 +30,8 @@ import { Directive, ElementRef, OnInit, Input, Output, EventEmitter } from '@ang
* If you only want to suppress a single event just pass the name of the event. If you want to suppress a set of events,
* pass an array with the names of the events to suppress.
*
* Usage of onClick instead of click is mandatory to make this directive work.
*
* Example usage:
*
* <ion-button [core-suppress-events] (onClick)="toggle($event)">
@ -51,6 +54,13 @@ export class CoreSupressEventsDirective implements OnInit {
* Initialize event listeners.
*/
ngOnInit(): void {
if (this.onClick.observers.length == 0) {
CoreLogger.getInstance('CoreSupressEventsDirective')
.error('No onClick output was defined causing this directive to fail', this.element);
return;
}
let events: string[];
if (this.suppressEvents == 'all' || typeof this.suppressEvents == 'undefined' || this.suppressEvents === null) {