diff --git a/ui/features/discussion_topics_post/react/DiscussionTopicManager.js b/ui/features/discussion_topics_post/react/DiscussionTopicManager.js index 822e815e78f..5029bc268b0 100644 --- a/ui/features/discussion_topics_post/react/DiscussionTopicManager.js +++ b/ui/features/discussion_topics_post/react/DiscussionTopicManager.js @@ -84,7 +84,7 @@ const DiscussionTopicManager = props => { }, [highlightEntryId]) const openIsolatedView = (discussionEntryId, rootEntryId, withRCE, relativeId = null) => { - setIsolatedEntryId(rootEntryId || discussionEntryId) + setIsolatedEntryId(discussionEntryId || rootEntryId) setReplyId(discussionEntryId) setIsolatedViewOpen(true) setEditorExpanded(withRCE) diff --git a/ui/features/discussion_topics_post/react/components/ThreadingToolbar/ThreadingToolbar.js b/ui/features/discussion_topics_post/react/components/ThreadingToolbar/ThreadingToolbar.js index f8923c57e91..3ea8adf4ac3 100644 --- a/ui/features/discussion_topics_post/react/components/ThreadingToolbar/ThreadingToolbar.js +++ b/ui/features/discussion_topics_post/react/components/ThreadingToolbar/ThreadingToolbar.js @@ -54,7 +54,7 @@ export function ThreadingToolbar({...props}) { data-testid="go-to-reply" onClick={() => { const isolatedId = props.discussionEntry.rootEntryId - ? props.discussionEntry.rootEntryId + ? props.discussionEntry.parentId || props.discussionEntry.rootEntryId : props.discussionEntry._id const relativeId = props.discussionEntry.rootEntryId ? props.discussionEntry._id diff --git a/ui/features/discussion_topics_post/react/components/ThreadingToolbar/__tests__/ThreadingToolbar.test.js b/ui/features/discussion_topics_post/react/components/ThreadingToolbar/__tests__/ThreadingToolbar.test.js index 19ff6865722..d3c179e1452 100644 --- a/ui/features/discussion_topics_post/react/components/ThreadingToolbar/__tests__/ThreadingToolbar.test.js +++ b/ui/features/discussion_topics_post/react/components/ThreadingToolbar/__tests__/ThreadingToolbar.test.js @@ -91,23 +91,52 @@ describe('PostToolbar', () => { expect(queryByText('Go to Reply')).toBeNull() }) - it('calls the onOpenIsolatedView callback with the root entry id', async () => { - window.ENV.isolated_view = true - const onOpenIsolatedView = jest.fn() - const container = render( - - ) + describe('when rootEntryId is present', () => { + it('calls the onOpenIsolatedView callback with the parent entry id', async () => { + window.ENV.isolated_view = true + const onOpenIsolatedView = jest.fn() + const container = render( + + ) - fireEvent.click(container.getByText('Go to Reply')) - await waitFor(() => expect(onOpenIsolatedView).toHaveBeenCalledWith('2', '2', false, '1', '1')) + fireEvent.click(container.getByText('Go to Reply')) + await waitFor(() => + expect(onOpenIsolatedView).toHaveBeenCalledWith('3', '2', false, '1', '1') + ) + }) + }) + + describe('when rootEntryId is not present', () => { + it('calls the onOpenIsolatedView callback with the entry id', async () => { + window.ENV.isolated_view = true + const onOpenIsolatedView = jest.fn() + const container = render( + + ) + + fireEvent.click(container.getByText('Go to Reply')) + await waitFor(() => + expect(onOpenIsolatedView).toHaveBeenCalledWith('1', null, false, null, '1') + ) + }) }) it('calls the onOpenIsolatedView callback with its own id if it is a root entry', async () => {