Fix page height on mobile.

Fix keyboard focus on mobile.
This commit is contained in:
Paul 2021-07-03 15:23:29 +01:00
parent 55633219f9
commit f25b488863
5 changed files with 14 additions and 6 deletions

View file

@ -1,7 +1,3 @@
// import classNames from "classnames";
// import { memo } from "preact/compat";
// import styles from "./TextArea.module.scss";
// import { useState, useEffect, useRef, useLayoutEffect } from "preact/hooks";
import styled, { css } from "styled-components"; import styled, { css } from "styled-components";
export interface TextAreaProps { export interface TextAreaProps {

View file

@ -2,6 +2,7 @@ import { isTouchscreenDevice } from "../lib/isTouchscreenDevice";
import { createGlobalStyle } from "styled-components"; import { createGlobalStyle } from "styled-components";
import { connectState } from "../redux/connector"; import { connectState } from "../redux/connector";
import { Children } from "../types/Preact"; import { Children } from "../types/Preact";
import { useEffect } from "preact/hooks";
import { createContext } from "preact"; import { createContext } from "preact";
import { Helmet } from "react-helmet"; import { Helmet } from "react-helmet";
@ -126,6 +127,14 @@ function Theme(props: Props) {
...props.options?.custom ...props.options?.custom
}; };
useEffect(() => {
const resize = () => document.documentElement.style.setProperty('--app-height', `${window.innerHeight}px`);
resize();
window.addEventListener('resize', resize);
return () => window.removeEventListener('resize', resize);
}, []);
return ( return (
<ThemeContext.Provider value={theme}> <ThemeContext.Provider value={theme}>
<Helmet> <Helmet>

View file

@ -1,6 +1,7 @@
import TextArea, { DEFAULT_LINE_HEIGHT, DEFAULT_TEXT_AREA_PADDING, TextAreaProps, TEXT_AREA_BORDER_WIDTH } from "../components/ui/TextArea";
import { useEffect, useRef } from "preact/hooks"; import { useEffect, useRef } from "preact/hooks";
import { internalSubscribe } from "./eventEmitter"; import { internalSubscribe } from "./eventEmitter";
import { isTouchscreenDevice } from "./isTouchscreenDevice";
import TextArea, { DEFAULT_LINE_HEIGHT, DEFAULT_TEXT_AREA_PADDING, TextAreaProps, TEXT_AREA_BORDER_WIDTH } from "../components/ui/TextArea";
type TextAreaAutoSizeProps = Omit<JSX.HTMLAttributes<HTMLTextAreaElement>, 'style' | 'value'> & TextAreaProps & { type TextAreaAutoSizeProps = Omit<JSX.HTMLAttributes<HTMLTextAreaElement>, 'style' | 'value'> & TextAreaProps & {
forceFocus?: boolean forceFocus?: boolean
@ -33,6 +34,7 @@ export default function TextAreaAutoSize(props: TextAreaAutoSizeProps) {
ref.current.focus(); ref.current.focus();
} }
if (isTouchscreenDevice) return;
if (autoFocus && !inputSelected()) { if (autoFocus && !inputSelected()) {
ref.current.focus(); ref.current.focus();
} }

View file

@ -41,7 +41,7 @@ export default function App() {
return ( return (
<OverlappingPanels <OverlappingPanels
width="100vw" width="100vw"
height="100vh" height="var(--app-height)"
leftPanel={inSpecial ? undefined : { width: 292, component: <LeftSidebar /> }} leftPanel={inSpecial ? undefined : { width: 292, component: <LeftSidebar /> }}
rightPanel={(!inSettings && inChannel) ? { width: 240, component: <RightSidebar /> } : undefined} rightPanel={(!inSettings && inChannel) ? { width: 240, component: <RightSidebar /> } : undefined}
bottomNav={{ bottomNav={{

View file

@ -1,3 +1,4 @@
:root { :root {
--app-height: 100vh;
--sidebar-active: var(--secondary-background); --sidebar-active: var(--secondary-background);
} }