MOBILE-3320 core: Prevent new line to be shown before submit
parent
5a15d1722f
commit
871a36f7a2
|
@ -1,7 +1,21 @@
|
|||
<form #messageForm>
|
||||
<textarea class="core-send-message-input" [core-auto-focus]="showKeyboard" [placeholder]="placeholder" rows="1" core-auto-rows
|
||||
[(ngModel)]="message" name="message" (onResize)="textareaResized()" (keyup.enter)="enterClicked($event)"
|
||||
(keyup.control.enter)="enterClicked($event, 'control')" (keyup.meta.enter)="enterClicked($event, 'meta')"></textarea>
|
||||
<textarea
|
||||
class="core-send-message-input"
|
||||
[core-auto-focus]="showKeyboard"
|
||||
[placeholder]="placeholder"
|
||||
rows="1"
|
||||
core-auto-rows
|
||||
[(ngModel)]="message"
|
||||
name="message"
|
||||
(onResize)="textareaResized()"
|
||||
(keyup.enter)="enterKeyUp($event)"
|
||||
(keyup.control.enter)="enterKeyUp($event, 'control')"
|
||||
(keyup.meta.enter)="enterKeyUp($event, 'meta')"
|
||||
(keydown.enter)="enterKeyDown($event)"
|
||||
(keydown.control.enter)="enterKeyDown($event, 'control')"
|
||||
(keydown.meta.enter)="enterKeyDown($event, 'meta')"
|
||||
>
|
||||
</textarea>
|
||||
<ion-button fill="clear" size="large" type="submit" [disabled]="!message || sendDisabled"
|
||||
[attr.aria-label]="'core.send' | translate" [core-suppress-events] (click)="submitForm($event)">
|
||||
<ion-icon name="send" color="dark" slot="icon-only" aria-hidden="true"></ion-icon>
|
||||
|
|
|
@ -103,13 +103,34 @@ export class CoreSendMessageFormComponent implements OnInit {
|
|||
this.onResize.emit();
|
||||
}
|
||||
|
||||
/**
|
||||
* A11y key functionality that prevents keyDown events.
|
||||
*
|
||||
* @param e Event.
|
||||
*/
|
||||
enterKeyDown(e: KeyboardEvent, other?: string): void {
|
||||
if (this.sendDisabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.sendOnEnter && !other) {
|
||||
// Enter clicked, send the message.
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
} else if (!this.sendOnEnter && !CoreApp.isMobile() && other == 'control') {
|
||||
// Cmd+Enter or Ctrl+Enter, send message.
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter key clicked.
|
||||
*
|
||||
* @param e Event.
|
||||
* @param other The name of the other key that was clicked, undefined if no other key.
|
||||
*/
|
||||
enterClicked(e: Event, other?: string): void {
|
||||
enterKeyUp(e: Event, other?: string): void {
|
||||
if (this.sendDisabled) {
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue