Commit 437ba3fb authored by Filipa Lacerda's avatar Filipa Lacerda

Prevent propagation of click even in job name inside dropdown.

parent 238ca048
...@@ -23,19 +23,13 @@ ...@@ -23,19 +23,13 @@
required: true, required: true,
}, },
}, },
mounted() {
/** updated() {
* When the user right clicks or cmd/ctrl + click in the job name or action icon, if (this.builds) {
* the dropdown should not be closed and the link should open in another tab. this.stopDropdownClickPropagation();
* If the target is a svg we stop propagation in order to prevent }
* the default behavior of the dropdown.
*/
console.log('I am called');
$('.js-builds-dropdown-list').on('click', (e) => {
console.log('i am in event');
e.stopPropagation();
});
}, },
methods: { methods: {
fetchBuilds(e) { fetchBuilds(e) {
const areaExpanded = e.currentTarget.attributes['aria-expanded']; const areaExpanded = e.currentTarget.attributes['aria-expanded'];
...@@ -50,6 +44,20 @@ ...@@ -50,6 +44,20 @@
return flash; return flash;
}); });
}, },
/**
* When the user right clicks or cmd/ctrl + click in the job name
* the dropdown should not be closed and the link should open in another tab,
* so we stop propagation of the click event inside the dropdown.
*
* Since this component is rendered multiple times per page we need to guarantee we only
* target the click event of this component.
*/
stopDropdownClickPropagation() {
$(this.$el.querySelectorAll('.js-builds-dropdown-list a.mini-pipeline-graph-dropdown-item')).on('click', (e) => {
e.stopPropagation();
});
},
}, },
computed: { computed: {
buildsOrSpinner() { buildsOrSpinner() {
......
...@@ -284,6 +284,18 @@ describe 'Pipelines', :feature, :js do ...@@ -284,6 +284,18 @@ describe 'Pipelines', :feature, :js do
expect(build.reload).to be_canceled expect(build.reload).to be_canceled
end end
end end
context 'dropdown jobs list' do
it 'should keep the dropdown open when the user ctr/cmd + clicks in the job name' do
find('.js-builds-dropdown-button').trigger('click')
execute_script('var e = $.Event("keydown", { keyCode: 64 }); $("body").trigger(e);')
find('.mini-pipeline-graph-dropdown-item').trigger('click')
expect(page).to have_selector('.js-ci-action-icon')
end
end
end end
context 'with pagination' do context 'with pagination' do
......
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