Virtual Keyboard does not restore height of the viewport to its initial when closed

61 Views Asked by At

I build telegram mini-apps using React. It uses web view to display apps in the telegram. Telegram is like whatsup(who doesn't know).

I stumbled upon this issue, repro steps:

  1. Create a bunch of inputs
  2. Click on the last one
  3. The keyboard appears and the screen scrolls to the focused input
  4. When the keyboard is closed the viewport is not restored to its initial size and the black empty space can be seen in the bottom of the screen.

How can I fix it?

Default View

enter image description here

Opened keyboard and focused input is being scrolled to

enter image description here

Keyboard is closed and black space can be seen

enter image description here

    <div className="bg-white h-[100vh] overflow-hidden relative flex flex-col gap-10">
      <input type="text" placeholder="test" className="bg-red-300" />
      <input type="text" placeholder="test" className="bg-red-300" />
      <input type="text" placeholder="test" className="bg-red-300" />
      <input type="text" placeholder="test" className="bg-red-300" />
      <input type="text" placeholder="test" className="bg-red-300" />
      <input type="text" placeholder="test" className="bg-red-300" />
      <input type="text" placeholder="test" className="bg-red-300" />
      <input type="text" placeholder="test" className="bg-red-300" />
      <input type="text" placeholder="test" className="bg-red-300" />
</div>
0

There are 0 best solutions below