select textarea at onload desktop view

This commit is contained in:
Chneemann 2024-05-28 03:42:41 +02:00
parent b5389130cb
commit 803e1feea2
2 changed files with 13 additions and 2 deletions

View file

@ -35,5 +35,6 @@
[currentChannel]="currentChannel" [currentChannel]="currentChannel"
(newMsgEmitter)="editMsgEmitter($event)" (newMsgEmitter)="editMsgEmitter($event)"
[target]="'chats'" [target]="'chats'"
[viewWidth]="viewWidth"
></app-chat-msg-box> ></app-chat-msg-box>
</section> </section>

View file

@ -22,6 +22,7 @@ import { User } from '../../../interface/user.interface';
import { MessageData } from '../../../interface/chat.interface'; import { MessageData } from '../../../interface/chat.interface';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { Channel } from '../../../interface/channel.interface'; import { Channel } from '../../../interface/channel.interface';
import { SharedService } from '../../../service/shared.service';
@Component({ @Component({
selector: 'app-chat-msg-box', selector: 'app-chat-msg-box',
@ -40,6 +41,7 @@ import { Channel } from '../../../interface/channel.interface';
export class ChatMsgBoxComponent { export class ChatMsgBoxComponent {
@Input() currentChannel: string = ''; @Input() currentChannel: string = '';
@Input() target: string = ''; @Input() target: string = '';
@Input() viewWidth: number = 0;
@Output() newMsgEmitter: EventEmitter<boolean> = new EventEmitter<boolean>(); @Output() newMsgEmitter: EventEmitter<boolean> = new EventEmitter<boolean>();
@ViewChild('textarea') textAreaRef!: ElementRef; @ViewChild('textarea') textAreaRef!: ElementRef;
@ -68,9 +70,12 @@ export class ChatMsgBoxComponent {
public userService: UserService, public userService: UserService,
private chatService: ChatService, private chatService: ChatService,
public channelService: ChannleService, public channelService: ChannleService,
public toggleBoolean: ToggleBooleanService public toggleBoolean: ToggleBooleanService,
private sharedService: SharedService
) {} ) {}
RESPONSIVE_THRESHOLD_MOBILE = this.sharedService.RESPONSIVE_THRESHOLD_MOBILE;
/** /**
* Handles the output from the emoji picker. * Handles the output from the emoji picker.
* @param $event The selected emoji. * @param $event The selected emoji.
@ -83,8 +88,13 @@ export class ChatMsgBoxComponent {
* Select Textarea at onload. * Select Textarea at onload.
*/ */
ngAfterViewInit() { ngAfterViewInit() {
if (
this.viewWidth != 0 &&
this.viewWidth >= this.RESPONSIVE_THRESHOLD_MOBILE
) {
this.textAreaRef.nativeElement.select(); this.textAreaRef.nativeElement.select();
} }
}
/** /**
* Handles file input change event. * Handles file input change event.