Commit 0a80f012 authored by Kushal Pandya's avatar Kushal Pandya

Prevent click from propagating to parent

Prevent Edit button click event from propagating further up which makes
datepicker hide immediately as soon as it shows up.
parent c7b04e81
......@@ -171,8 +171,9 @@ export default {
this.editing = false;
this.$emit('toggleDateType', true, true);
},
toggleDatePicker() {
toggleDatePicker(e) {
this.editing = !this.editing;
e.stopPropagation();
},
newDateSelected(date = null) {
this.editing = false;
......
......@@ -121,6 +121,16 @@ describe 'Update Epic', :js do
end
end
context 'epic sidebar' do
it 'opens datepicker when clicking Edit button' do
page.within('.issuable-sidebar .block.start-date') do
click_button('Edit')
expect(find('.value-type-fixed')).to have_selector('.pikaday-container')
expect(find('.value-type-fixed')).to have_selector('.pikaday-container .pika-single.is-bound')
end
end
end
it 'updates the tasklist' do
expect(page).to have_selector('ul.task-list', count: 1)
expect(page).to have_selector('li.task-list-item', count: 1)
......
......@@ -169,10 +169,14 @@ describe('SidebarDatePicker', () => {
describe('toggleDatePicker', () => {
it('flips value of `editing` prop from `true` to `false` and vice-versa', () => {
const e = new Event('click');
spyOn(e, 'stopPropagation');
vm.editing = true;
vm.toggleDatePicker();
vm.toggleDatePicker(e);
expect(vm.editing).toBe(false);
expect(e.stopPropagation).toHaveBeenCalled();
});
});
......
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