Fix textarea focus for touchscreens with keyboard (#30)

* check if touchscreen has mouse.

* add inputMode to props.

* fix formatting.
This commit is contained in:
Miroslav Šedivý
2023-04-18 10:19:52 +02:00
committed by GitHub
parent ddfa3a7aef
commit d3514b9698
2 changed files with 25 additions and 7 deletions

View File

@ -112,6 +112,9 @@
@Prop()
private readonly fps!: number
@Prop()
private readonly hasMobileKeyboard!: boolean
get cursor(): string {
if (!this.isControling || !this.cursorImage) {
return 'default'
@ -121,10 +124,6 @@
return 'url(' + uri + ') ' + x + ' ' + y + ', default'
}
get isTouchDevice(): boolean {
return 'ontouchstart' in window || navigator.maxTouchPoints > 0
}
mounted() {
// register mouseup globally as user can release mouse button outside of overlay
window.addEventListener('mouseup', this.onMouseUp, true)
@ -386,7 +385,7 @@
onMouseEnter(e: MouseEvent) {
// focus opens the keyboard on mobile (only for android)
if (!this.isTouchDevice) {
if (!this.hasMobileKeyboard) {
this._textarea.focus()
}
@ -678,7 +677,7 @@
public mobileKeyboardShow() {
// skip if not a touch device
if (!this.isTouchDevice) return
if (!this.hasMobileKeyboard) return
this.kbdShow = true
this.kbdOpen = false
@ -690,7 +689,7 @@
public mobileKeyboardHide() {
// skip if not a touch device
if (!this.isTouchDevice) return
if (!this.hasMobileKeyboard) return
this.kbdShow = false
this.kbdOpen = false