-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
35380 virtual viewport on report screen #38755
Changes from 9 commits
b692714
750d321
4df3eb8
52e6585
14232fe
9215e2d
967184b
8114339
5f3f51c
1f8265c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,8 @@ const useEmojiPickerMenu = () => { | |
const [preferredSkinTone] = usePreferredEmojiSkinTone(); | ||
const {windowHeight} = useWindowDimensions(); | ||
const StyleUtils = useStyleUtils(); | ||
const listStyle = StyleUtils.getEmojiPickerListHeight(isListFiltered, windowHeight); | ||
// calculate the height of the emoji picker based popoverInnerContainer style has maxHeight is 95% | ||
const listStyle = StyleUtils.getEmojiPickerListHeight(isListFiltered, windowHeight * 0.95); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With some small screen size devices (ie: iPhone SE), we might need to reduce the max height when the keyboard opens. |
||
|
||
useEffect(() => { | ||
setFilteredEmojis(allEmojis); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/** | ||
* Native doesn't support DOM so default value is 0 | ||
*/ | ||
|
||
export default function useViewportOffsetTop(): number { | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,51 @@ | ||||||||||
import {useEffect, useRef, useState} from 'react'; | ||||||||||
import addViewportResizeListener from '@libs/VisualViewport'; | ||||||||||
|
||||||||||
/** | ||||||||||
* A hook that returns the offset of the top edge of the visual viewport | ||||||||||
*/ | ||||||||||
export default function useViewportOffsetTop(shouldAdjustScrollView = false): number { | ||||||||||
const [viewportOffsetTop, setViewportOffsetTop] = useState(0); | ||||||||||
const initialHeight = useRef(window.visualViewport?.height ?? window.innerHeight).current; | ||||||||||
const cachedDefaultOffsetTop = useRef<number>(0); | ||||||||||
useEffect(() => { | ||||||||||
const updateOffsetTop = (event?: Event) => { | ||||||||||
let targetOffsetTop = window.visualViewport?.offsetTop ?? 0; | ||||||||||
if (event?.target instanceof VisualViewport) { | ||||||||||
targetOffsetTop = event.target.offsetTop; | ||||||||||
} | ||||||||||
|
||||||||||
if (shouldAdjustScrollView && window.visualViewport) { | ||||||||||
const adjustScrollY = Math.round(initialHeight - window.visualViewport.height); | ||||||||||
if (cachedDefaultOffsetTop.current === 0) { | ||||||||||
cachedDefaultOffsetTop.current = targetOffsetTop; | ||||||||||
} | ||||||||||
|
||||||||||
if (adjustScrollY > targetOffsetTop) { | ||||||||||
setViewportOffsetTop(adjustScrollY); | ||||||||||
} else if (targetOffsetTop !== 0 && adjustScrollY === targetOffsetTop) { | ||||||||||
setViewportOffsetTop(cachedDefaultOffsetTop.current); | ||||||||||
} else { | ||||||||||
setViewportOffsetTop(targetOffsetTop); | ||||||||||
} | ||||||||||
} else { | ||||||||||
setViewportOffsetTop(targetOffsetTop); | ||||||||||
} | ||||||||||
}; | ||||||||||
updateOffsetTop(); | ||||||||||
const removeViewportResizeListener = addViewportResizeListener(updateOffsetTop); | ||||||||||
|
||||||||||
return () => { | ||||||||||
removeViewportResizeListener(); | ||||||||||
}; | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function is not needed right?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes I have cleanup this function |
||||||||||
}, [initialHeight, shouldAdjustScrollView]); | ||||||||||
|
||||||||||
useEffect(() => { | ||||||||||
if (!shouldAdjustScrollView) { | ||||||||||
return; | ||||||||||
} | ||||||||||
window.scrollTo({top: viewportOffsetTop}); | ||||||||||
}, [shouldAdjustScrollView, viewportOffsetTop]); | ||||||||||
|
||||||||||
return viewportOffsetTop; | ||||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update the comment to explain why 95%?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated explain the reason for 95%