diff options
author | Heinrich Lee Yu <heinrich@gitlab.com> | 2019-08-22 13:48:29 +0800 |
---|---|---|
committer | Heinrich Lee Yu <heinrich@gitlab.com> | 2019-08-29 09:35:58 +0800 |
commit | 88cf7591c7bc38b7dbd70085ea3b93813acc14f8 (patch) | |
tree | 42b20d0039cbda92de6f71caa4b08ed162e5170d | |
parent | b34120336d33e57d9817559f82771f8da4f5f2b3 (diff) | |
download | gitlab-ce-fix-dropdown-closing.tar.gz |
Fix dropdown closing when mouseup is outsidefix-dropdown-closing
Changes the document event listener to listen to
mousedown instead of click
-rw-r--r-- | app/assets/javascripts/droplab/drop_lab.js | 4 | ||||
-rw-r--r-- | changelogs/unreleased/fix-dropdown-closing.yml | 5 | ||||
-rw-r--r-- | spec/support/features/discussion_comments_shared_example.rb | 2 |
3 files changed, 8 insertions, 3 deletions
diff --git a/app/assets/javascripts/droplab/drop_lab.js b/app/assets/javascripts/droplab/drop_lab.js index 1339e28d8b8..33c05404493 100644 --- a/app/assets/javascripts/droplab/drop_lab.js +++ b/app/assets/javascripts/droplab/drop_lab.js @@ -60,7 +60,7 @@ class DropLab { addEvents() { this.eventWrapper.documentClicked = this.documentClicked.bind(this); - document.addEventListener('click', this.eventWrapper.documentClicked); + document.addEventListener('mousedown', this.eventWrapper.documentClicked); } documentClicked(e) { @@ -74,7 +74,7 @@ class DropLab { } removeEvents() { - document.removeEventListener('click', this.eventWrapper.documentClicked); + document.removeEventListener('mousedown', this.eventWrapper.documentClicked); } changeHookList(trigger, list, plugins, config) { diff --git a/changelogs/unreleased/fix-dropdown-closing.yml b/changelogs/unreleased/fix-dropdown-closing.yml new file mode 100644 index 00000000000..5ce3a6b478e --- /dev/null +++ b/changelogs/unreleased/fix-dropdown-closing.yml @@ -0,0 +1,5 @@ +--- +title: Fix dropdowns closing when click is released outside the dropdown +merge_request: 32084 +author: +type: fixed diff --git a/spec/support/features/discussion_comments_shared_example.rb b/spec/support/features/discussion_comments_shared_example.rb index 5590bf0fb7e..f070243f111 100644 --- a/spec/support/features/discussion_comments_shared_example.rb +++ b/spec/support/features/discussion_comments_shared_example.rb @@ -73,7 +73,7 @@ shared_examples 'thread comments' do |resource_name| expect(page).not_to have_selector menu_selector find(toggle_selector).click - execute_script("document.querySelector('body').click()") + find("#{form_selector} .note-textarea").click expect(page).not_to have_selector menu_selector end |