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 a4ccf58376bf99fc437bb2cd31e7fffb41363c59..689e58c05c489f4fc27abe14d06e52be305faf3f 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 bfa9330c6b879890ea5a1f0f7002b3ffd944409e..0eff89b6bddb5d506b2124d12df54cb72627d410 100644 --- a/src/app/components/shared/room-join/room-join.component.ts +++ b/src/app/components/shared/room-join/room-join.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, ViewChild, ElementRef } from '@angular/core'; import { Room } from '../../../models/room'; import { RoomService } from '../../../services/http/room.service'; import { Router } from '@angular/router'; @@ -24,6 +24,7 @@ export class JoinErrorStateMatcher implements ErrorStateMatcher { styleUrls: ['./room-join.component.scss'] }) export class RoomJoinComponent implements OnInit { + @ViewChild('roomId') roomIdElement: ElementRef; room: Room; demoId = '95680586'; @@ -41,9 +42,14 @@ export class RoomJoinComponent implements OnInit { } ngOnInit() { + this.roomIdElement.nativeElement.focus(); 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 => {