Skip to content
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

[WIP] Update Yellow Highlight Dismissal Behavior #43581

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import * as Report from '@userActions/Report';
import * as User from '@userActions/User';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import {getClearIsReportActionLinked} from '@src/pages/home/report/clearReportAction';
import type * as OnyxTypes from '@src/types/onyx';
import type * as OnyxCommon from '@src/types/onyx/OnyxCommon';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
Expand Down Expand Up @@ -230,6 +231,8 @@ function ReportActionCompose({

const onItemSelected = useCallback(() => {
isKeyboardVisibleWhenShowingModalRef.current = false;
// Clear the highlighted report item when an action from the + menu is taken
getClearIsReportActionLinked()();
}, []);

const updateShouldShowSuggestionMenuToFalse = useCallback(() => {
Expand Down Expand Up @@ -274,6 +277,8 @@ function ReportActionCompose({
Performance.markStart(CONST.TIMING.MESSAGE_SENT, {message: newCommentTrimmed});
onSubmit(newCommentTrimmed);
}
// Clear the highlighted report item when a new comment or attachment is sent
getClearIsReportActionLinked()();
},
[onSubmit, reportID],
);
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ type ReportActionItemProps = {
/** Flag to show, hide the thread divider line */
shouldHideThreadDividerLine?: boolean;

/** Linked report action ID */
linkedReportActionID?: string;

/** Callback to be called on onPress */
Expand Down
19 changes: 18 additions & 1 deletion src/pages/home/report/ReportActionsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import type * as OnyxTypes from '@src/types/onyx';
import {setClearIsReportActionLinked} from './clearReportAction';
import FloatingMessageCounter from './FloatingMessageCounter';
import getInitialNumToRender from './getInitialNumReportActionsToRender';
import ListBoundaryLoader from './ListBoundaryLoader';
Expand Down Expand Up @@ -184,7 +185,23 @@ function ReportActionsList({
const readActionSkipped = useRef(false);
const hasHeaderRendered = useRef(false);
const hasFooterRendered = useRef(false);
const linkedReportActionID = route?.params?.reportActionID ?? '-1';
const [linkedReportActionID, setLinkedReportActionID] = useState(route?.params?.reportActionID ?? '-1');

const clearIsReportActionLinked = useCallback(() => {
setLinkedReportActionID('-1');
}, []);

useEffect(() => {
setClearIsReportActionLinked(clearIsReportActionLinked);
}, [clearIsReportActionLinked]);

useEffect(() => {
if (route?.params?.reportActionID) {
setLinkedReportActionID(route.params.reportActionID);
} else {
setLinkedReportActionID('-1');
}
}, [route]);

const sortedVisibleReportActions = useMemo(
() =>
Expand Down
9 changes: 9 additions & 0 deletions src/pages/home/report/clearReportAction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
let clearIsReportActionLinked: () => void = () => {};

const setClearIsReportActionLinked = (fn: () => void) => {
clearIsReportActionLinked = fn;
};

const getClearIsReportActionLinked = () => clearIsReportActionLinked;

export {setClearIsReportActionLinked, getClearIsReportActionLinked};
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import * as Task from '@userActions/Task';
import CONST from '@src/CONST';
import type {TranslationPaths} from '@src/languages/types';
import ONYXKEYS from '@src/ONYXKEYS';
import {getClearIsReportActionLinked} from '@src/pages/home/report/clearReportAction';
import ROUTES from '@src/ROUTES';
import SCREENS from '@src/SCREENS';
import type * as OnyxTypes from '@src/types/onyx';
Expand Down Expand Up @@ -351,13 +352,19 @@ function FloatingActionButtonAndPopover(
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
const selfDMReportID = useMemo(() => ReportUtils.findSelfDMReportID(), [isLoading]);

const onItemSelected = useCallback(() => {
hideCreateMenu();
// Clear the highlighted report item when an action from the + menu is taken
getClearIsReportActionLinked()();
}, [hideCreateMenu]);

return (
<View style={styles.flexGrow1}>
<PopoverMenu
onClose={hideCreateMenu}
isVisible={isCreateMenuActive && (!shouldUseNarrowLayout || isFocused)}
anchorPosition={styles.createMenuPositionSidebar(windowHeight)}
onItemSelected={hideCreateMenu}
onItemSelected={onItemSelected}
fromSidebarMediumScreen={!shouldUseNarrowLayout}
menuItems={[
{
Expand Down
Loading