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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
196a3c54
Commit
196a3c54
authored
Jun 06, 2017
by
Clement Ho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change from double click to single click to open dropdown
parent
02a877ac
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
64 deletions
+22
-64
app/assets/javascripts/filtered_search/filtered_search_manager.js
...ts/javascripts/filtered_search/filtered_search_manager.js
+7
-19
app/assets/stylesheets/framework/filters.scss
app/assets/stylesheets/framework/filters.scss
+9
-7
changelogs/unreleased/31757-single-click-on-filter-in-search-bar-to-activate-dropdown.yml
...le-click-on-filter-in-search-bar-to-activate-dropdown.yml
+4
-0
spec/features/issues/filtered_search/visual_tokens_spec.rb
spec/features/issues/filtered_search/visual_tokens_spec.rb
+2
-2
spec/javascripts/filtered_search/filtered_search_manager_spec.js
...vascripts/filtered_search/filtered_search_manager_spec.js
+0
-36
No files found.
app/assets/javascripts/filtered_search/filtered_search_manager.js
View file @
196a3c54
...
@@ -105,11 +105,9 @@ class FilteredSearchManager {
...
@@ -105,11 +105,9 @@ class FilteredSearchManager {
this
.
filteredSearchInput
.
addEventListener
(
'
click
'
,
this
.
tokenChange
);
this
.
filteredSearchInput
.
addEventListener
(
'
click
'
,
this
.
tokenChange
);
this
.
filteredSearchInput
.
addEventListener
(
'
keyup
'
,
this
.
tokenChange
);
this
.
filteredSearchInput
.
addEventListener
(
'
keyup
'
,
this
.
tokenChange
);
this
.
filteredSearchInput
.
addEventListener
(
'
focus
'
,
this
.
addInputContainerFocusWrapper
);
this
.
filteredSearchInput
.
addEventListener
(
'
focus
'
,
this
.
addInputContainerFocusWrapper
);
this
.
tokensContainer
.
addEventListener
(
'
click
'
,
FilteredSearchManager
.
selectToken
);
this
.
tokensContainer
.
addEventListener
(
'
click
'
,
this
.
removeTokenWrapper
);
this
.
tokensContainer
.
addEventListener
(
'
click
'
,
this
.
removeTokenWrapper
);
this
.
tokensContainer
.
addEventListener
(
'
dbl
click
'
,
this
.
editTokenWrapper
);
this
.
tokensContainer
.
addEventListener
(
'
click
'
,
this
.
editTokenWrapper
);
this
.
clearSearchButton
.
addEventListener
(
'
click
'
,
this
.
onClearSearchWrapper
);
this
.
clearSearchButton
.
addEventListener
(
'
click
'
,
this
.
onClearSearchWrapper
);
document
.
addEventListener
(
'
click
'
,
gl
.
FilteredSearchVisualTokens
.
unselectTokens
);
document
.
addEventListener
(
'
click
'
,
this
.
unselectEditTokensWrapper
);
document
.
addEventListener
(
'
click
'
,
this
.
unselectEditTokensWrapper
);
document
.
addEventListener
(
'
click
'
,
this
.
removeInputContainerFocusWrapper
);
document
.
addEventListener
(
'
click
'
,
this
.
removeInputContainerFocusWrapper
);
document
.
addEventListener
(
'
keydown
'
,
this
.
removeSelectedTokenKeydownWrapper
);
document
.
addEventListener
(
'
keydown
'
,
this
.
removeSelectedTokenKeydownWrapper
);
...
@@ -127,11 +125,9 @@ class FilteredSearchManager {
...
@@ -127,11 +125,9 @@ class FilteredSearchManager {
this
.
filteredSearchInput
.
removeEventListener
(
'
click
'
,
this
.
tokenChange
);
this
.
filteredSearchInput
.
removeEventListener
(
'
click
'
,
this
.
tokenChange
);
this
.
filteredSearchInput
.
removeEventListener
(
'
keyup
'
,
this
.
tokenChange
);
this
.
filteredSearchInput
.
removeEventListener
(
'
keyup
'
,
this
.
tokenChange
);
this
.
filteredSearchInput
.
removeEventListener
(
'
focus
'
,
this
.
addInputContainerFocusWrapper
);
this
.
filteredSearchInput
.
removeEventListener
(
'
focus
'
,
this
.
addInputContainerFocusWrapper
);
this
.
tokensContainer
.
removeEventListener
(
'
click
'
,
FilteredSearchManager
.
selectToken
);
this
.
tokensContainer
.
removeEventListener
(
'
click
'
,
this
.
removeTokenWrapper
);
this
.
tokensContainer
.
removeEventListener
(
'
click
'
,
this
.
removeTokenWrapper
);
this
.
tokensContainer
.
removeEventListener
(
'
dbl
click
'
,
this
.
editTokenWrapper
);
this
.
tokensContainer
.
removeEventListener
(
'
click
'
,
this
.
editTokenWrapper
);
this
.
clearSearchButton
.
removeEventListener
(
'
click
'
,
this
.
onClearSearchWrapper
);
this
.
clearSearchButton
.
removeEventListener
(
'
click
'
,
this
.
onClearSearchWrapper
);
document
.
removeEventListener
(
'
click
'
,
gl
.
FilteredSearchVisualTokens
.
unselectTokens
);
document
.
removeEventListener
(
'
click
'
,
this
.
unselectEditTokensWrapper
);
document
.
removeEventListener
(
'
click
'
,
this
.
unselectEditTokensWrapper
);
document
.
removeEventListener
(
'
click
'
,
this
.
removeInputContainerFocusWrapper
);
document
.
removeEventListener
(
'
click
'
,
this
.
removeInputContainerFocusWrapper
);
document
.
removeEventListener
(
'
keydown
'
,
this
.
removeSelectedTokenKeydownWrapper
);
document
.
removeEventListener
(
'
keydown
'
,
this
.
removeSelectedTokenKeydownWrapper
);
...
@@ -207,23 +203,13 @@ class FilteredSearchManager {
...
@@ -207,23 +203,13 @@ class FilteredSearchManager {
}
}
}
}
static
selectToken
(
e
)
{
const
button
=
e
.
target
.
closest
(
'
.selectable
'
);
const
removeButtonSelected
=
e
.
target
.
closest
(
'
.remove-token
'
);
if
(
!
removeButtonSelected
&&
button
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
gl
.
FilteredSearchVisualTokens
.
selectToken
(
button
);
}
}
removeToken
(
e
)
{
removeToken
(
e
)
{
const
removeButtonSelected
=
e
.
target
.
closest
(
'
.remove-token
'
);
const
removeButtonSelected
=
e
.
target
.
closest
(
'
.remove-token
'
);
if
(
removeButtonSelected
)
{
if
(
removeButtonSelected
)
{
e
.
preventDefault
();
e
.
preventDefault
();
e
.
stopPropagation
();
// Prevent editToken from being triggered after token is removed
e
.
stopImmediatePropagation
();
const
button
=
e
.
target
.
closest
(
'
.selectable
'
);
const
button
=
e
.
target
.
closest
(
'
.selectable
'
);
gl
.
FilteredSearchVisualTokens
.
selectToken
(
button
,
true
);
gl
.
FilteredSearchVisualTokens
.
selectToken
(
button
,
true
);
...
@@ -245,10 +231,12 @@ class FilteredSearchManager {
...
@@ -245,10 +231,12 @@ class FilteredSearchManager {
editToken
(
e
)
{
editToken
(
e
)
{
const
token
=
e
.
target
.
closest
(
'
.js-visual-token
'
);
const
token
=
e
.
target
.
closest
(
'
.js-visual-token
'
);
const
sanitizedTokenName
=
token
.
querySelector
(
'
.name
'
).
textContent
.
trim
();
const
sanitizedTokenName
=
token
&&
token
.
querySelector
(
'
.name
'
).
textContent
.
trim
();
const
canEdit
=
this
.
canEdit
&&
this
.
canEdit
(
sanitizedTokenName
);
const
canEdit
=
this
.
canEdit
&&
this
.
canEdit
(
sanitizedTokenName
);
if
(
token
&&
canEdit
)
{
if
(
token
&&
canEdit
)
{
e
.
preventDefault
();
e
.
stopPropagation
();
gl
.
FilteredSearchVisualTokens
.
editToken
(
token
);
gl
.
FilteredSearchVisualTokens
.
editToken
(
token
);
this
.
tokenChange
();
this
.
tokenChange
();
}
}
...
...
app/assets/stylesheets/framework/filters.scss
View file @
196a3c54
...
@@ -142,8 +142,11 @@
...
@@ -142,8 +142,11 @@
}
}
}
}
}
}
}
.selected
{
.filtered-search-token
:hover
,
.filtered-search-token
.selected
,
.filtered-search-term
.selected
{
.name
{
.name
{
background-color
:
$filter-name-selected-color
;
background-color
:
$filter-name-selected-color
;
}
}
...
@@ -151,7 +154,6 @@
...
@@ -151,7 +154,6 @@
.value-container
{
.value-container
{
background-color
:
$filter-value-selected-color
;
background-color
:
$filter-value-selected-color
;
}
}
}
}
}
.filtered-search-term
{
.filtered-search-term
{
...
...
changelogs/unreleased/31757-single-click-on-filter-in-search-bar-to-activate-dropdown.yml
0 → 100644
View file @
196a3c54
---
title
:
Single click on filter to open filtered search dropdown
merge_request
:
author
:
spec/features/issues/filtered_search/visual_tokens_spec.rb
View file @
196a3c54
...
@@ -34,7 +34,7 @@ describe 'Visual tokens', js: true, feature: true do
...
@@ -34,7 +34,7 @@ describe 'Visual tokens', js: true, feature: true do
describe
'editing author token'
do
describe
'editing author token'
do
before
do
before
do
input_filtered_search
(
'author:@root assignee:none'
,
submit:
false
)
input_filtered_search
(
'author:@root assignee:none'
,
submit:
false
)
first
(
'.tokens-container .filtered-search-token'
).
double_
click
first
(
'.tokens-container .filtered-search-token'
).
click
end
end
it
'opens author dropdown'
do
it
'opens author dropdown'
do
...
@@ -331,7 +331,7 @@ describe 'Visual tokens', js: true, feature: true do
...
@@ -331,7 +331,7 @@ describe 'Visual tokens', js: true, feature: true do
it
'does not tokenize incomplete token'
do
it
'does not tokenize incomplete token'
do
filtered_search
.
send_keys
(
'author:'
)
filtered_search
.
send_keys
(
'author:'
)
find
(
'
#content-
body'
).
click
find
(
'body'
).
click
token
=
page
.
all
(
'.tokens-container .js-visual-token'
)[
1
]
token
=
page
.
all
(
'.tokens-container .js-visual-token'
)[
1
]
expect_filtered_search_input_empty
expect_filtered_search_input_empty
...
...
spec/javascripts/filtered_search/filtered_search_manager_spec.js
View file @
196a3c54
...
@@ -316,42 +316,6 @@ describe('Filtered Search Manager', () => {
...
@@ -316,42 +316,6 @@ describe('Filtered Search Manager', () => {
});
});
});
});
describe
(
'
unselects token
'
,
()
=>
{
beforeEach
(()
=>
{
tokensContainer
.
innerHTML
=
FilteredSearchSpecHelper
.
createTokensContainerHTML
(
`
${
FilteredSearchSpecHelper
.
createFilterVisualTokenHTML
(
'
label
'
,
'
~bug
'
,
true
)}
${
FilteredSearchSpecHelper
.
createSearchVisualTokenHTML
(
'
search term
'
)}
${
FilteredSearchSpecHelper
.
createFilterVisualTokenHTML
(
'
label
'
,
'
~awesome
'
)}
`
);
});
it
(
'
unselects token when input is clicked
'
,
()
=>
{
const
selectedToken
=
tokensContainer
.
querySelector
(
'
.js-visual-token .selected
'
);
expect
(
selectedToken
.
classList
.
contains
(
'
selected
'
)).
toEqual
(
true
);
expect
(
gl
.
FilteredSearchVisualTokens
.
unselectTokens
).
not
.
toHaveBeenCalled
();
// Click directly on input attached to document
// so that the click event will propagate properly
document
.
querySelector
(
'
.filtered-search
'
).
click
();
expect
(
gl
.
FilteredSearchVisualTokens
.
unselectTokens
).
toHaveBeenCalled
();
expect
(
selectedToken
.
classList
.
contains
(
'
selected
'
)).
toEqual
(
false
);
});
it
(
'
unselects token when document.body is clicked
'
,
()
=>
{
const
selectedToken
=
tokensContainer
.
querySelector
(
'
.js-visual-token .selected
'
);
expect
(
selectedToken
.
classList
.
contains
(
'
selected
'
)).
toEqual
(
true
);
expect
(
gl
.
FilteredSearchVisualTokens
.
unselectTokens
).
not
.
toHaveBeenCalled
();
document
.
body
.
click
();
expect
(
selectedToken
.
classList
.
contains
(
'
selected
'
)).
toEqual
(
false
);
expect
(
gl
.
FilteredSearchVisualTokens
.
unselectTokens
).
toHaveBeenCalled
();
});
});
describe
(
'
toggleInputContainerFocus
'
,
()
=>
{
describe
(
'
toggleInputContainerFocus
'
,
()
=>
{
it
(
'
toggles on focus
'
,
()
=>
{
it
(
'
toggles on focus
'
,
()
=>
{
input
.
focus
();
input
.
focus
();
...
...
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