Commit c6ee2a3e authored by Nathan Friend's avatar Nathan Friend

Fix hash parameter of Permalink and Blame buttons

This commit fixes the logic that updates the href of the Permalink and
Blame buttons so that the href is updated regardless of what element
within the line number link is clicked.
parent 9603ebdc
...@@ -11,7 +11,7 @@ export default () => { ...@@ -11,7 +11,7 @@ export default () => {
// eslint-disable-next-line no-new // eslint-disable-next-line no-new
new BlobLinePermalinkUpdater( new BlobLinePermalinkUpdater(
document.querySelector('#blob-content-holder'), document.querySelector('#blob-content-holder'),
'.diff-line-num[data-line-number]', '.diff-line-num[data-line-number], .diff-line-num[data-line-number] *',
document.querySelectorAll('.js-data-file-blob-permalink-url, .js-blob-blame-link'), document.querySelectorAll('.js-data-file-blob-permalink-url, .js-blob-blame-link'),
); );
......
---
title: Fix hash parameter of Permalink and Blame button
merge_request: 23713
author:
type: fixed
...@@ -44,6 +44,17 @@ describe 'Blob button line permalinks (BlobLinePermalinkUpdater)', :js do ...@@ -44,6 +44,17 @@ describe 'Blob button line permalinks (BlobLinePermalinkUpdater)', :js do
expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: ending_fragment))) expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: ending_fragment)))
end end
it 'changes fragment hash if icon inside line number link is clicked' do
ending_fragment = "L7"
visit_blob
find("##{ending_fragment}").hover
find("##{ending_fragment} i").click
expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: ending_fragment)))
end
it 'with initial fragment hash, changes fragment hash if line number clicked' do it 'with initial fragment hash, changes fragment hash if line number clicked' do
fragment = "L1" fragment = "L1"
ending_fragment = "L5" ending_fragment = "L5"
...@@ -83,6 +94,17 @@ describe 'Blob button line permalinks (BlobLinePermalinkUpdater)', :js do ...@@ -83,6 +94,17 @@ describe 'Blob button line permalinks (BlobLinePermalinkUpdater)', :js do
expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: ending_fragment))) expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: ending_fragment)))
end end
it 'changes fragment hash if icon inside line number link is clicked' do
ending_fragment = "L7"
visit_blob
find("##{ending_fragment}").hover
find("##{ending_fragment} i").click
expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: ending_fragment)))
end
it 'with initial fragment hash, changes fragment hash if line number clicked' do it 'with initial fragment hash, changes fragment hash if line number clicked' do
fragment = "L1" fragment = "L1"
ending_fragment = "L5" ending_fragment = "L5"
......
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