Skip to content

Commit

Permalink
cleanup condition adjust scroll view for web
Browse files Browse the repository at this point in the history
  • Loading branch information
suneox committed Apr 10, 2024
1 parent 0376ede commit 283e46f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/hooks/useViewportOffsetTop/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {useCallback, useEffect, useRef, useState} from 'react';
import * as Browser from '@libs/Browser';
import addViewportResizeListener from '@libs/VisualViewport';

/**
Expand All @@ -15,7 +16,7 @@ export default function useViewportOffsetTop(shouldAdjustScrollView = false): nu
targetOffsetTop = event.target.offsetTop;
}

if (shouldAdjustScrollView && window.visualViewport) {
if (Browser.isMobileSafari() && shouldAdjustScrollView && window.visualViewport) {
const clientHeight = document.body.clientHeight;
const adjustScrollY = Math.round(clientHeight - window.visualViewport.height);
if (cachedDefaultOffsetTop.current === 0) {
Expand Down
3 changes: 1 addition & 2 deletions src/pages/home/ReportScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import useThemeStyles from '@hooks/useThemeStyles';
import useViewportOffsetTop from '@hooks/useViewportOffsetTop';
import useWindowDimensions from '@hooks/useWindowDimensions';
import Timing from '@libs/actions/Timing';
import * as Browser from '@libs/Browser';
import Navigation from '@libs/Navigation/Navigation';
import clearReportNotifications from '@libs/Notification/clearReportNotifications';
import Performance from '@libs/Performance';
Expand Down Expand Up @@ -275,7 +274,7 @@ function ReportScreen({
Performance.markStart(CONST.TIMING.CHAT_RENDER);
}
const [isComposerFocus, setIsComposerFocus] = useState(false);
const shouldAdjustScrollView = useMemo(() => Browser.isMobileSafari() && isComposerFocus && !modal?.willAlertModalBecomeVisible, [isComposerFocus, modal]);
const shouldAdjustScrollView = useMemo(() => isComposerFocus && !modal?.willAlertModalBecomeVisible, [isComposerFocus, modal]);
const viewportOffsetTop = useViewportOffsetTop(shouldAdjustScrollView);

const {reportPendingAction, reportErrors} = ReportUtils.getReportOfflinePendingActionAndErrors(report);
Expand Down

0 comments on commit 283e46f

Please sign in to comment.