From fb2fa61fbb9bcd167229204c0980e35d09c96e13 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 19 Dec 2024 13:03:51 +0800 Subject: [PATCH 1/5] fix tooltip wrong position --- .../home/report/ReportActionCompose/ReportActionCompose.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx index 893d2b3060d9..3b62a629b381 100644 --- a/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx @@ -30,6 +30,7 @@ import useNetwork from '@hooks/useNetwork'; import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; +import useViewportOffsetTop from '@hooks/useViewportOffsetTop'; import canFocusInputOnScreenFocus from '@libs/canFocusInputOnScreenFocus'; import * as DeviceCapabilities from '@libs/DeviceCapabilities'; import DomUtils from '@libs/DomUtils'; @@ -121,6 +122,7 @@ function ReportActionCompose({ const {translate} = useLocalize(); // eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth const {isSmallScreenWidth, isMediumScreenWidth, shouldUseNarrowLayout} = useResponsiveLayout(); + const offsetTop = useViewportOffsetTop(); const {isOffline} = useNetwork(); const actionButtonRef = useRef(null); const currentUserPersonalDetails = useCurrentUserPersonalDetails(); @@ -458,7 +460,7 @@ function ReportActionCompose({ }} wrapperStyle={styles.reportActionComposeTooltipWrapper} shiftHorizontal={variables.composerTooltipShiftHorizontal} - shiftVertical={variables.composerTooltipShiftVertical} + shiftVertical={variables.composerTooltipShiftVertical + offsetTop} > Date: Thu, 19 Dec 2024 15:17:49 +0800 Subject: [PATCH 2/5] lint --- .../ComposerWithSuggestions/ComposerWithSuggestions.tsx | 4 ++-- .../home/report/ReportActionCompose/ReportActionCompose.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index 7b0d6663facf..114deb609a57 100644 --- a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -146,7 +146,7 @@ type ComposerWithSuggestionsProps = Partial & { isGroupPolicyReport: boolean; /** policy ID of the report */ - policyID: string; + policyID: string | undefined; }; type SwitchToCurrentReportProps = { @@ -274,7 +274,7 @@ function ComposerWithSuggestions( const {shouldUseNarrowLayout} = useResponsiveLayout(); const maxComposerLines = shouldUseNarrowLayout ? CONST.COMPOSER.MAX_LINES_SMALL_SCREEN : CONST.COMPOSER.MAX_LINES; - const parentReportAction = useMemo(() => parentReportActions?.[parentReportActionID ?? '-1'], [parentReportActionID, parentReportActions]); + const parentReportAction = useMemo(() => parentReportActionID ? parentReportActions?.[parentReportActionID] : undefined, [parentReportActionID, parentReportActions]); const shouldAutoFocus = !modal?.isVisible && Modal.areAllModalsHidden() && diff --git a/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx b/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx index 3b62a629b381..4f431b7dff6f 100644 --- a/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx +++ b/src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx @@ -325,7 +325,7 @@ function ReportActionCompose({ // We are returning a callback here as we want to incoke the method on unmount only useEffect( () => () => { - if (!EmojiPickerActions.isActive(report?.reportID ?? '-1')) { + if (!report?.reportID || !EmojiPickerActions.isActive(report.reportID)) { return; } EmojiPickerActions.hideEmojiPicker(); @@ -516,7 +516,7 @@ function ReportActionCompose({ isScrollLikelyLayoutTriggered={isScrollLikelyLayoutTriggered} raiseIsScrollLikelyLayoutTriggered={raiseIsScrollLikelyLayoutTriggered} reportID={reportID} - policyID={report?.policyID ?? '-1'} + policyID={report?.policyID} parentReportID={report?.parentReportID} parentReportActionID={report?.parentReportActionID} includeChronos={ReportUtils.chatIncludesChronos(report)} From 03b6b54d651768ec0c8f611cb3555fb66fec2525 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 19 Dec 2024 15:43:17 +0800 Subject: [PATCH 3/5] prettier --- .../ComposerWithSuggestions/ComposerWithSuggestions.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index 114deb609a57..2285ad99c24a 100644 --- a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -274,7 +274,7 @@ function ComposerWithSuggestions( const {shouldUseNarrowLayout} = useResponsiveLayout(); const maxComposerLines = shouldUseNarrowLayout ? CONST.COMPOSER.MAX_LINES_SMALL_SCREEN : CONST.COMPOSER.MAX_LINES; - const parentReportAction = useMemo(() => parentReportActionID ? parentReportActions?.[parentReportActionID] : undefined, [parentReportActionID, parentReportActions]); + const parentReportAction = useMemo(() => (parentReportActionID ? parentReportActions?.[parentReportActionID] : undefined), [parentReportActionID, parentReportActions]); const shouldAutoFocus = !modal?.isVisible && Modal.areAllModalsHidden() && From 74cb7896837de9af45f00b4779a53fa4d9c79e94 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 19 Dec 2024 17:09:52 +0800 Subject: [PATCH 4/5] suppress lint --- .../ComposerWithSuggestions/ComposerWithSuggestions.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index 2285ad99c24a..4345a219e039 100644 --- a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -263,7 +263,7 @@ function ComposerWithSuggestions( const [modal] = useOnyx(ONYXKEYS.MODAL); const [preferredSkinTone = CONST.EMOJI_DEFAULT_SKIN_TONE] = useOnyx(ONYXKEYS.PREFERRED_EMOJI_SKIN_TONE, {selector: EmojiUtils.getPreferredSkinToneIndex}); const [editFocused] = useOnyx(ONYXKEYS.INPUT_FOCUSED); - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, rulesdir/no-default-id-values const [parentReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID || '-1'}`, {canEvict: false, initWithStoredValues: false}); const lastTextRef = useRef(value); From 3c7be905b1066dacc8c64c0175fb7ec53a8bda45 Mon Sep 17 00:00:00 2001 From: Bernhard Owen Josephus Date: Thu, 19 Dec 2024 17:14:47 +0800 Subject: [PATCH 5/5] lint --- .../ComposerWithSuggestions/ComposerWithSuggestions.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx index 4345a219e039..94b4ce43e78e 100644 --- a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx +++ b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx @@ -263,8 +263,8 @@ function ComposerWithSuggestions( const [modal] = useOnyx(ONYXKEYS.MODAL); const [preferredSkinTone = CONST.EMOJI_DEFAULT_SKIN_TONE] = useOnyx(ONYXKEYS.PREFERRED_EMOJI_SKIN_TONE, {selector: EmojiUtils.getPreferredSkinToneIndex}); const [editFocused] = useOnyx(ONYXKEYS.INPUT_FOCUSED); - // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing, rulesdir/no-default-id-values - const [parentReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID || '-1'}`, {canEvict: false, initWithStoredValues: false}); + // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing + const [parentReportActions] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${parentReportID || CONST.DEFAULT_NUMBER_ID}`, {canEvict: false, initWithStoredValues: false}); const lastTextRef = useRef(value); useEffect(() => {