From 18bd9d62cbc0d454000f33f2d2abfd850ef373ac Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 25 Aug 2021 13:40:38 +0530 Subject: [PATCH] fixed #71 : input autofocus on touch devices --- src/app/organisms/channel/ChannelViewInput.jsx | 1 + src/client/state/settings.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/app/organisms/channel/ChannelViewInput.jsx b/src/app/organisms/channel/ChannelViewInput.jsx index 6e5deb0..773b47d 100644 --- a/src/app/organisms/channel/ChannelViewInput.jsx +++ b/src/app/organisms/channel/ChannelViewInput.jsx @@ -134,6 +134,7 @@ function ChannelViewInput({ } function focusInput() { + if (settings.isTouchScreenDevice) return; textAreaRef.current.focus(); } diff --git a/src/client/state/settings.js b/src/client/state/settings.js index fcbf4be..9516d86 100644 --- a/src/client/state/settings.js +++ b/src/client/state/settings.js @@ -24,6 +24,8 @@ class Settings extends EventEmitter { this.themeIndex = this.getThemeIndex(); this.isMarkdown = this.getIsMarkdown(); + + this.isTouchScreenDevice = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0); } getThemeIndex() {