Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
d785eca7
Commit
d785eca7
authored
Mar 16, 2021
by
Simon Stieger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't close issue label select box on click if only mouseup outside
parent
b8b97284
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
10 deletions
+43
-10
app/assets/javascripts/vue_shared/components/sidebar/labels_select_vue/labels_select_root.vue
...mponents/sidebar/labels_select_vue/labels_select_root.vue
+38
-10
changelogs/unreleased/dont-close-label-auto-suggest-select-box-if-only-mouseup-outside-box.yml
...l-auto-suggest-select-box-if-only-mouseup-outside-box.yml
+5
-0
No files found.
app/assets/javascripts/vue_shared/components/sidebar/labels_select_vue/labels_select_root.vue
View file @
d785eca7
...
...
@@ -172,9 +172,11 @@ export default {
after
:
this
.
handleVuexActionDispatch
,
});
document
.
addEventListener
(
'
mousedown
'
,
this
.
handleDocumentMousedown
);
document
.
addEventListener
(
'
click
'
,
this
.
handleDocumentClick
);
},
beforeDestroy
()
{
document
.
removeEventListener
(
'
mousedown
'
,
this
.
handleDocumentMousedown
);
document
.
removeEventListener
(
'
click
'
,
this
.
handleDocumentClick
);
},
methods
:
{
...
...
@@ -196,12 +198,37 @@ export default {
this
.
handleDropdownClose
(
state
.
labels
.
filter
(
filterFn
));
}
},
/**
* This method stores a mousedown event's target.
* Required by the click listener because the click
* event itself has no reference to this element.
*/
handleDocumentMousedown
({
target
})
{
this
.
mousedownTarget
=
target
;
},
/**
* This method listens for document-wide click event
* and toggle dropdown if user clicks anywhere outside
* the dropdown while dropdown is visible.
*/
handleDocumentClick
({
target
})
{
// We also perform the toggle exception check for the
// last mousedown event's target to avoid hiding the
// box when the mousedown happened inside the box and
// only the mouseup did not.
if
(
this
.
showDropdownContents
&&
!
this
.
preventDropdownToggleOnClick
(
target
)
&&
!
this
.
preventDropdownToggleOnClick
(
this
.
mousedownTarget
)
)
{
this
.
toggleDropdownContents
();
}
},
/**
* This method checks whether a given click target
* should prevent the dropdown from being toggled.
*/
preventDropdownToggleOnClick
(
target
)
{
// This approach of element detection is needed
// as the dropdown wrapper is not using `GlDropdown` as
// it will also require us to use `BDropdownForm`
...
...
@@ -216,19 +243,20 @@ export default {
target
?.
parentElement
?.
classList
.
contains
(
className
),
);
const
ha
d
ExceptionParent
=
[
'
.js-btn-back
'
,
'
.js-labels-list
'
].
some
(
const
ha
s
ExceptionParent
=
[
'
.js-btn-back
'
,
'
.js-labels-list
'
].
some
(
(
className
)
=>
$
(
target
).
parents
(
className
).
length
,
);
if
(
this
.
showDropdownContents
&&
!
hadExceptionParent
&&
!
hasExceptionClass
&&
!
this
.
$refs
.
dropdownButtonCollapsed
?.
$el
.
contains
(
target
)
&&
!
this
.
$refs
.
dropdownContents
?.
$el
.
contains
(
target
)
)
{
this
.
toggleDropdownContents
();
}
const
isInDropdownButtonCollapsed
=
this
.
$refs
.
dropdownButtonCollapsed
?.
$el
.
contains
(
target
);
const
isInDropdownContents
=
this
.
$refs
.
dropdownContents
?.
$el
.
contains
(
target
);
return
(
hasExceptionClass
||
hasExceptionParent
||
isInDropdownButtonCollapsed
||
isInDropdownContents
);
},
handleDropdownClose
(
labels
)
{
// Only emit label updates if there are any labels to update
...
...
changelogs/unreleased/dont-close-label-auto-suggest-select-box-if-only-mouseup-outside-box.yml
0 → 100644
View file @
d785eca7
---
title
:
Don't close issue label select box on click if only mouseup outside
merge_request
:
56721
author
:
Simon Stieger @sim0
type
:
fixed
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment