Skip to content

Commit 7119760

Browse files
committed
[WIP] Fix Android keyboard vh distortion
1 parent 06f916b commit 7119760

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/components/contact-form.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@ import React, { useState } from "react"
22
import { Trans } from 'gatsby-plugin-react-i18next';
33
import styled from 'styled-components';
44

5-
65
import { AiOutlineMail } from 'react-icons/ai';
76
import { BsFillPersonFill } from 'react-icons/bs'
87
import { ButtonRed } from "./button";
98

109
export default function ContactForm() {
10+
const initialHeight = window.innerHeight;
11+
12+
const setViewPortHeightToOriginal = () => {
13+
const viewport = document.querySelector(`meta[name=viewport]`);
14+
if (window.innerHeight < initialHeight) {
15+
document.documentElement.style.setProperty("overflow", "auto")
16+
viewport.setAttribute(`content`, `height=` + initialHeight + `px, width=device-width, initial-scale=1.0`)
17+
}
18+
}
1119
const [formState, setFormState] = useState({
1220
name: "",
1321
email: "",
@@ -41,6 +49,7 @@ export default function ContactForm() {
4149

4250
const handleFocus = e => {
4351
// TODO: fix android keyboard distortion on keyboard
52+
setViewPortHeightToOriginal();
4453
const input = e.currentTarget;
4554
const group = input.parentElement;
4655
const label = group.firstChild;

0 commit comments

Comments
 (0)