diff --git a/src/components/ChatBotContainer.tsx b/src/components/ChatBotContainer.tsx index d619bd9e..3852c77c 100644 --- a/src/components/ChatBotContainer.tsx +++ b/src/components/ChatBotContainer.tsx @@ -137,13 +137,22 @@ const ChatBotContainer = ({ flow }: { flow: Flow }) => { const { x, y, width, height } = event.target.boundingRect; // width does not need adjustments so only height is adjusted if (x == 0 && y == 0 && width == 0 && height == 0) { + // delay added as it takes time for keyboard to appear and resize the viewport height setTimeout(() => { setViewportHeight(window.visualViewport?.height as number); - }, 501); + }, 101); + + // a second check added in case device lags and needs a later resizing + setTimeout(() => { + if (viewportHeight != window.visualViewport?.height as number) { + setViewportHeight(window.visualViewport?.height as number); + } + }, 1001); } else { + // delay added as it takes time for keyboard to disappear and resize the viewport height setTimeout(() => { setViewportHeight(window.visualViewport?.height as number - height); - }, 501); + }, 101); } }); }