From 9c4e6625d04582d3404c806b328064ce02aa0976 Mon Sep 17 00:00:00 2001 From: truph01 Date: Tue, 12 Nov 2024 22:27:07 +0700 Subject: [PATCH] add comment to useEffect --- src/hooks/useIsWindowHeightReducedByKeyboard/index.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/hooks/useIsWindowHeightReducedByKeyboard/index.ts b/src/hooks/useIsWindowHeightReducedByKeyboard/index.ts index b1b79ffb01e9..7895c7209115 100644 --- a/src/hooks/useIsWindowHeightReducedByKeyboard/index.ts +++ b/src/hooks/useIsWindowHeightReducedByKeyboard/index.ts @@ -18,6 +18,12 @@ const useIsWindowHeightReducedByKeyboard = () => { [shouldUseNarrowLayout], ); useEffect(() => { + // Use window height changes to toggle the keyboard. To maintain keyboard state + // on all platforms we also use focus/blur events. So we need to make sure here + // that we avoid redundant keyboard toggling. + // Minus 100px is needed to make sure that when the internet connection is + // disabled in android chrome and a small 'No internet connection' text box appears, + // we do not take it as a sign to open the keyboard if (!isWindowHeightReducedByKeyboard && windowHeight < prevWindowHeight - 100) { toggleKeyboardOnSmallScreens(true); } else if (isWindowHeightReducedByKeyboard && windowHeight > prevWindowHeight) {