1
0
Fork 0

Disable auto-focus markdown textarea on touchdevices

This commit is contained in:
kimsible 2020-11-17 15:45:06 +01:00 committed by Chocobozzz
parent 363726fe9a
commit aa9cf3b98d
1 changed files with 6 additions and 2 deletions

View File

@ -4,7 +4,7 @@ import { Subject } from 'rxjs'
import { debounceTime, distinctUntilChanged } from 'rxjs/operators' import { debounceTime, distinctUntilChanged } from 'rxjs/operators'
import { Component, ElementRef, forwardRef, Input, OnInit, ViewChild } from '@angular/core' import { Component, ElementRef, forwardRef, Input, OnInit, ViewChild } from '@angular/core'
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
import { MarkdownService } from '@app/core' import { MarkdownService, ScreenService } from '@app/core'
@Component({ @Component({
selector: 'my-markdown-textarea', selector: 'my-markdown-textarea',
@ -40,6 +40,7 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit {
constructor ( constructor (
private viewportScroller: ViewportScroller, private viewportScroller: ViewportScroller,
private screenService: ScreenService,
private markdownService: MarkdownService private markdownService: MarkdownService
) { } ) { }
@ -80,7 +81,10 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit {
this.isMaximized = !this.isMaximized this.isMaximized = !this.isMaximized
// Make sure textarea have the focus // Make sure textarea have the focus
this.textareaElement.nativeElement.focus() // Except on touchscreens devices, the virtual keyboard may move up and hide the textarea in maximized mode
if (!this.screenService.isInTouchScreen()) {
this.textareaElement.nativeElement.focus()
}
// Make sure the window has no scrollbars // Make sure the window has no scrollbars
if (!this.isMaximized) { if (!this.isMaximized) {