-
Notifications
You must be signed in to change notification settings - Fork 4k
Scroll to and focus the message put into edit mode by ArrowUp #100432
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ import useMarkAsRead from '@hooks/useMarkAsRead'; | |
| import useNetwork from '@hooks/useNetwork'; | ||
| import useOnyx from '@hooks/useOnyx'; | ||
| import useReportActionsScroll from '@hooks/useReportActionsScroll'; | ||
| import useReportScrollManager from '@hooks/useReportScrollManager'; | ||
| import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
| import useUnreadMarker from '@hooks/useUnreadMarker'; | ||
|
|
@@ -64,6 +65,7 @@ import {isTrackIntentUserSelector} from '@selectors/Onboarding'; | |
| import React, {useEffect, useRef, useState} from 'react'; | ||
|
|
||
| import FloatingMessageCounter from './FloatingMessageCounter'; | ||
| import {useReportActionActiveEdit, useReportActionActiveEditActions} from './ReportActionEditMessageContext'; | ||
| import ReportActionIndexContext from './ReportActionIndexContext'; | ||
| import {useReportActionsListActions, useReportActionsListState} from './ReportActionsListContext'; | ||
| import ReportActionsListHeader from './ReportActionsListHeader'; | ||
|
|
@@ -258,6 +260,27 @@ function ReportActionsListContent({reportID, conciergeChat, onLayout}: ReportAct | |
| revealDraftFromReportAction(persistedDraftReportAction); | ||
| }, [draftReportAction, persistedDraftReportAction, revealDraftFromReportAction]); | ||
|
|
||
| // A message put into edit mode from the composer (ArrowUp) can sit outside the list's render window, so its editor never mounts and never | ||
| // takes focus. Scroll to it here, where the rendered indexes are known, so the row mounts and the message stays visible while it's edited. | ||
| const {pendingScrollToEditingReportActionID} = useReportActionActiveEdit(); | ||
|
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.
While a message is being edited, Useful? React with 👍 / 👎. |
||
| const {clearPendingScrollToEditingAction} = useReportActionActiveEditActions(); | ||
| const reportScrollManager = useReportScrollManager(); | ||
|
|
||
| useEffect(() => { | ||
| if (!pendingScrollToEditingReportActionID) { | ||
| return; | ||
| } | ||
|
|
||
| clearPendingScrollToEditingAction(); | ||
|
|
||
| const editingReportActionIndex = renderedVisibleReportActions.findIndex((action) => action.reportActionID === pendingScrollToEditingReportActionID); | ||
| if (editingReportActionIndex < 0) { | ||
| return; | ||
| } | ||
|
|
||
| reportScrollManager.scrollToIndex(editingReportActionIndex); | ||
| }, [clearPendingScrollToEditingAction, pendingScrollToEditingReportActionID, renderedVisibleReportActions, reportScrollManager]); | ||
|
|
||
| // Find the index of the action badge target in the rendered actions list (which is what the FlatList uses as data) | ||
| const actionBadgeTargetID = reportAttributes?.actionTargetReportActionID; | ||
| const actionBadgeTargetIndex = actionBadgeTargetID ? renderedVisibleReportActions.findIndex((action) => action.reportActionID === actionBadgeTargetID) : -1; | ||
|
|
||
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.
When an expense report takes the
shouldDisplayMoneyRequestActionsListbranch inMoneyRequestReportView, this shared composer still creates the request, but onlyReportActionsListconsumes it;MoneyRequestReportActionsListnever reads or clears the request. If the newest editable comment is outside that unified FlashList's render window, pressing ArrowUp therefore still leaves the inline editor unmounted and unfocused. Handle the request in both list implementations or place the handling in their shared list infrastructure.Useful? React with 👍 / 👎.