diff --git a/packages/web/src/javascripts/App.tsx b/packages/web/src/javascripts/App.tsx index 1414e4c65..a98415b8a 100644 --- a/packages/web/src/javascripts/App.tsx +++ b/packages/web/src/javascripts/App.tsx @@ -42,10 +42,19 @@ const getKey = () => { } const setViewportHeight = () => { - document.documentElement.style.setProperty( - '--viewport-height', - `${visualViewport ? visualViewport.height : window.innerHeight}px`, - ) + const currentValue = parseInt(document.documentElement.style.getPropertyValue('--viewport-height')) + const newValue = visualViewport && visualViewport.height > 0 ? visualViewport.height : window.innerHeight + + if (currentValue && !newValue) { + return + } + + if (!currentValue && !newValue) { + document.documentElement.style.setProperty('--viewport-height', '100vh') + return + } + + document.documentElement.style.setProperty('--viewport-height', `${newValue}px`) } const setDefaultMonospaceFont = (platform?: Platform) => {