Skip to content

Commit

Permalink
Merge pull request #47993 from bernhardoj/fix/45524-message-highlight…
Browse files Browse the repository at this point in the history
…-is-stukck

Fix message highlight stuck when open the 2nd context menu
  • Loading branch information
roryabraham authored Aug 27, 2024
2 parents 6de0766 + 3be4772 commit 9fbed40
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef<Repor
} else {
anchorRef.current = null;
}
setInstanceID(Math.random().toString(36).substr(2, 5));

onPopoverShow.current = onShow;
onPopoverHide.current = onHide;
Expand Down Expand Up @@ -226,6 +225,7 @@ function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef<Repor

/** After Popover shows, call the registered onPopoverShow callback and reset it */
const runAndResetOnPopoverShow = () => {
setInstanceID(Math.random().toString(36).substr(2, 5));
onPopoverShow.current();

// After we have called the action, reset it.
Expand All @@ -243,6 +243,7 @@ function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef<Repor
reportIDRef.current = '-1';
reportActionIDRef.current = '-1';
originalReportIDRef.current = '-1';
setInstanceID('');

onPopoverHide.current = runAndResetCallback(onPopoverHide.current);
onPopoverHideActionCallback.current = runAndResetCallback(onPopoverHideActionCallback.current);
Expand Down
48 changes: 26 additions & 22 deletions src/pages/home/report/ContextMenu/ReportActionContextMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,33 +123,37 @@ function showContextMenu(
if (!contextMenuRef.current) {
return;
}
const show = () => {
contextMenuRef.current?.showContextMenu(
type,
event,
selection,
contextMenuAnchor,
reportID,
reportActionID,
originalReportID,
draftMessage,
onShow,
onHide,
isArchivedRoom,
isChronosReport,
isPinnedChat,
isUnreadChat,
disabledActions,
shouldCloseOnTarget,
setIsEmojiPickerActive,
isOverflowMenu,
);
};

// If there is an already open context menu, close it first before opening
// a new one.
if (contextMenuRef.current.instanceID) {
hideContextMenu();
contextMenuRef.current.runAndResetOnPopoverHide();
hideContextMenu(false, show);
return;
}

contextMenuRef.current.showContextMenu(
type,
event,
selection,
contextMenuAnchor,
reportID,
reportActionID,
originalReportID,
draftMessage,
onShow,
onHide,
isArchivedRoom,
isChronosReport,
isPinnedChat,
isUnreadChat,
disabledActions,
shouldCloseOnTarget,
setIsEmojiPickerActive,
isOverflowMenu,
);
show();
}

/**
Expand Down

0 comments on commit 9fbed40

Please sign in to comment.