From 64d727f2443cd3cea5becd14c5df7236fec61627 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=20K=C3=A4sler?= <tom.kaesler@mni.thm.de>
Date: Mon, 20 May 2019 22:43:25 +0200
Subject: [PATCH] Join room on enter

---
 src/app/components/shared/room-join/room-join.component.html | 2 +-
 src/app/components/shared/room-join/room-join.component.ts   | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/app/components/shared/room-join/room-join.component.html b/src/app/components/shared/room-join/room-join.component.html
index a4ccf5837..689e58c05 100644
--- a/src/app/components/shared/room-join/room-join.component.html
+++ b/src/app/components/shared/room-join/room-join.component.html
@@ -1,7 +1,7 @@
 <div fxLayout="column" fxLayoutAlign="center center" fxlayoutgap="50px" fxFill>
 <form (ngSubmit)="joinRoom(roomId.value)">
   <div fxLayout="row" fxLayoutAlign="center" fxLayoutGap="10px">
-    <mat-form-field>
+    <mat-form-field (keyup.enter)="onEnter()">
       <input matInput #roomId type="text" pattern="[0-9 ]*" inputmode="numeric" min="00000000" max="99999999"
              onkeydown="if(this.value.length - (this.value.split(' ').length -1) === 8 && event.keyCode != 8) return false;
                         if(this.value.length === 4 && event.keyCode != 8) this.value = this.value + ' ';"
diff --git a/src/app/components/shared/room-join/room-join.component.ts b/src/app/components/shared/room-join/room-join.component.ts
index e3508026a..0eff89b6b 100644
--- a/src/app/components/shared/room-join/room-join.component.ts
+++ b/src/app/components/shared/room-join/room-join.component.ts
@@ -46,6 +46,10 @@ export class RoomJoinComponent implements OnInit {
     this.authenticationService.watchUser.subscribe(newUser => this.user = newUser);
   }
 
+  onEnter() {
+    this.getRoom(this.roomIdElement.nativeElement.value);
+  }
+
   getRoom(id: string): void {
     if (id.length - (id.split(' ').length - 1) < 8) {
       this.translateService.get('home-page.exactly-8').subscribe(message => {
-- 
GitLab