Commit 1b70276a authored by Phil Hughes's avatar Phil Hughes

Fixed jump to next discussion button not working

Fixes the jump to next discusion which could be caused by
the discussion not returning correctly

Closes https://gitlab.com/gitlab-org/gitlab/-/issues/232802
parent 7d532353
......@@ -166,8 +166,6 @@ export default class MergeRequestTabs {
if (this.setUrl) {
this.setCurrentAction(action);
}
this.eventHub.$emit('MergeRequestTabChange', this.getCurrentAction());
}
}
}
......@@ -251,6 +249,8 @@ export default class MergeRequestTabs {
}
}
}
this.eventHub.$emit('MergeRequestTabChange', action);
}
scrollToElement(container) {
......
......@@ -78,7 +78,7 @@ function handleDiscussionJump(self, fn, discussionId = self.currentDiscussionId)
const isDiffView = window.mrTabs.currentAction === 'diffs';
const targetId = fn(discussionId, isDiffView);
const discussion = self.getDiscussion(targetId);
const discussionFilePath = discussion.diff_file?.file_path;
const discussionFilePath = discussion?.diff_file?.file_path;
if (discussionFilePath) {
self.scrollToFile(discussionFilePath);
......
......@@ -194,7 +194,9 @@ export const findUnresolvedDiscussionIdNeighbor = (state, getters) => ({
diffOrder,
step,
}) => {
const ids = getters.unresolvedDiscussionsIdsOrdered(diffOrder);
const diffIds = getters.unresolvedDiscussionsIdsOrdered(diffOrder);
const dateIds = getters.unresolvedDiscussionsIdsOrdered(false);
const ids = diffIds.length ? diffIds : dateIds;
const index = ids.indexOf(discussionId) + step;
if (index < 0 && step < 0) {
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'User jumps to the next unresolved discussion', :js do
let(:project) { create(:project, :repository) }
let(:merge_request) do
create(:merge_request_with_diffs, source_project: project, target_project: project, source_branch: 'merge-test')
end
let(:user) { create(:user) }
before do
create(:discussion_note, noteable: merge_request, project: project, author: user)
project.add_maintainer(user)
sign_in(user)
visit(diffs_project_merge_request_path(project, merge_request))
wait_for_requests
end
it 'jumps to overview tab' do
find('.discussion-next-btn').click
expect(page).to have_css('.notes-tab.active')
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment