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
19677dd4
Commit
19677dd4
authored
Mar 10, 2017
by
Clement Ho
Committed by
Alfredo Sumaran
Mar 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add filter focus for filtered search visual tokens
parent
0eff4f14
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
4 deletions
+49
-4
app/assets/javascripts/filtered_search/filtered_search_manager.js
...ts/javascripts/filtered_search/filtered_search_manager.js
+23
-0
app/assets/stylesheets/framework/filters.scss
app/assets/stylesheets/framework/filters.scss
+14
-4
spec/javascripts/filtered_search/filtered_search_manager_spec.js
...vascripts/filtered_search/filtered_search_manager_spec.js
+12
-0
No files found.
app/assets/javascripts/filtered_search/filtered_search_manager.js
View file @
19677dd4
...
...
@@ -40,6 +40,8 @@ import FilteredSearchContainer from './container';
this
.
unselectEditTokensWrapper
=
this
.
unselectEditTokens
.
bind
(
this
);
this
.
editTokenWrapper
=
this
.
editToken
.
bind
(
this
);
this
.
tokenChange
=
this
.
tokenChange
.
bind
(
this
);
this
.
addInputContainerFocusWrapper
=
this
.
addInputContainerFocus
.
bind
(
this
);
this
.
removeInputContainerFocusWrapper
=
this
.
removeInputContainerFocus
.
bind
(
this
);
this
.
filteredSearchInputForm
=
this
.
filteredSearchInput
.
form
;
this
.
filteredSearchInputForm
.
addEventListener
(
'
submit
'
,
this
.
handleFormSubmit
);
...
...
@@ -51,11 +53,13 @@ import FilteredSearchContainer from './container';
this
.
filteredSearchInput
.
addEventListener
(
'
keyup
'
,
this
.
checkForBackspaceWrapper
);
this
.
filteredSearchInput
.
addEventListener
(
'
click
'
,
this
.
tokenChange
);
this
.
filteredSearchInput
.
addEventListener
(
'
keyup
'
,
this
.
tokenChange
);
this
.
filteredSearchInput
.
addEventListener
(
'
focus
'
,
this
.
addInputContainerFocusWrapper
);
this
.
tokensContainer
.
addEventListener
(
'
click
'
,
FilteredSearchManager
.
selectToken
);
this
.
tokensContainer
.
addEventListener
(
'
dblclick
'
,
this
.
editTokenWrapper
);
this
.
clearSearchButton
.
addEventListener
(
'
click
'
,
this
.
clearSearchWrapper
);
document
.
addEventListener
(
'
click
'
,
gl
.
FilteredSearchVisualTokens
.
unselectTokens
);
document
.
addEventListener
(
'
click
'
,
this
.
unselectEditTokensWrapper
);
document
.
addEventListener
(
'
click
'
,
this
.
removeInputContainerFocusWrapper
);
document
.
addEventListener
(
'
keydown
'
,
this
.
removeSelectedTokenWrapper
);
}
...
...
@@ -69,11 +73,13 @@ import FilteredSearchContainer from './container';
this
.
filteredSearchInput
.
removeEventListener
(
'
keyup
'
,
this
.
checkForBackspaceWrapper
);
this
.
filteredSearchInput
.
removeEventListener
(
'
click
'
,
this
.
tokenChange
);
this
.
filteredSearchInput
.
removeEventListener
(
'
keyup
'
,
this
.
tokenChange
);
this
.
filteredSearchInput
.
removeEventListener
(
'
focus
'
,
this
.
addInputContainerFocusWrapper
);
this
.
tokensContainer
.
removeEventListener
(
'
click
'
,
FilteredSearchManager
.
selectToken
);
this
.
tokensContainer
.
removeEventListener
(
'
dblclick
'
,
this
.
editTokenWrapper
);
this
.
clearSearchButton
.
removeEventListener
(
'
click
'
,
this
.
clearSearchWrapper
);
document
.
removeEventListener
(
'
click
'
,
gl
.
FilteredSearchVisualTokens
.
unselectTokens
);
document
.
removeEventListener
(
'
click
'
,
this
.
unselectEditTokensWrapper
);
document
.
removeEventListener
(
'
click
'
,
this
.
removeInputContainerFocusWrapper
);
document
.
removeEventListener
(
'
keydown
'
,
this
.
removeSelectedTokenWrapper
);
}
...
...
@@ -124,6 +130,23 @@ import FilteredSearchContainer from './container';
}
}
addInputContainerFocus
()
{
this
.
filteredSearchInput
.
closest
(
'
.filtered-search-input-container
'
).
classList
.
add
(
'
focus
'
);
}
removeInputContainerFocus
(
e
)
{
const
inputContainer
=
this
.
filteredSearchInput
.
closest
(
'
.filtered-search-input-container
'
);
const
isElementInFilteredSearch
=
inputContainer
&&
inputContainer
.
contains
(
e
.
target
);
const
isElementInDynamicFilterDropdown
=
e
.
target
.
closest
(
'
.filter-dropdown
'
)
!==
null
;
const
isElementInStaticFilterDropdown
=
e
.
target
.
closest
(
'
ul[data-dropdown]
'
)
!==
null
;
if
(
!
isElementInFilteredSearch
&&
!
isElementInDynamicFilterDropdown
&&
!
isElementInStaticFilterDropdown
)
{
inputContainer
.
classList
.
remove
(
'
focus
'
);
}
}
static
selectToken
(
e
)
{
const
button
=
e
.
target
.
closest
(
'
.selectable
'
);
...
...
app/assets/stylesheets/framework/filters.scss
View file @
19677dd4
...
...
@@ -171,6 +171,20 @@
}
}
&
:hover
{
@extend
.form-control
:hover
;
}
&
.focus
,
&
.focus
:hover
{
border-color
:
$dropdown-input-focus-border
;
box-shadow
:
0
0
4px
$search-input-focus-shadow-color
;
}
&
.focus
.fa-filter
{
color
:
$common-gray-dark
;
}
.form-control
{
position
:
relative
;
min-width
:
200px
;
...
...
@@ -178,10 +192,6 @@
padding-right
:
25px
;
border-color
:
transparent
;
&
:focus
~
.fa-filter
{
color
:
$common-gray-dark
;
}
&
:focus
,
&
:hover
{
outline
:
none
;
...
...
spec/javascripts/filtered_search/filtered_search_manager_spec.js
View file @
19677dd4
...
...
@@ -246,5 +246,17 @@ const FilteredSearchSpecHelper = require('../helpers/filtered_search_spec_helper
expect
(
gl
.
FilteredSearchVisualTokens
.
unselectTokens
).
toHaveBeenCalled
();
});
});
describe
(
'
toggleInputContainerFocus
'
,
()
=>
{
it
(
'
toggles on focus
'
,
()
=>
{
input
.
focus
();
expect
(
document
.
querySelector
(
'
.filtered-search-input-container
'
).
classList
.
contains
(
'
focus
'
)).
toEqual
(
true
);
});
it
(
'
toggles on blur
'
,
()
=>
{
input
.
blur
();
expect
(
document
.
querySelector
(
'
.filtered-search-input-container
'
).
classList
.
contains
(
'
focus
'
)).
toEqual
(
false
);
});
});
});
})();
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