Skip to content

Commit

Permalink
add comment to useEffect
Browse files Browse the repository at this point in the history
  • Loading branch information
truph01 committed Nov 12, 2024
1 parent 937064c commit 9c4e662
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/hooks/useIsWindowHeightReducedByKeyboard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 9c4e662

Please sign in to comment.