BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
ecf08ae1
Commit
ecf08ae1
authored
Jan 20, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed some issues with droplab & keyboard navigation
Added specs
parent
3680612a
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
16 deletions
+69
-16
droplab.js
app/assets/javascripts/droplab/droplab.js
+41
-16
droplab_ajax_filter.js
app/assets/javascripts/droplab/droplab_ajax_filter.js
+1
-0
droplab_filter.js
app/assets/javascripts/droplab/droplab_filter.js
+1
-0
dropdown_label_spec.rb
spec/features/issues/filtered_search/dropdown_label_spec.rb
+10
-0
search_bar_spec.rb
spec/features/issues/filtered_search/search_bar_spec.rb
+16
-0
No files found.
app/assets/javascripts/droplab/droplab.js
View file @
ecf08ae1
...
...
@@ -165,15 +165,21 @@ Object.assign(DropDown.prototype, {
},
show
:
function
()
{
if
(
this
.
hidden
)
{
// debugger
this
.
list
.
style
.
display
=
'block'
;
this
.
currentIndex
=
0
;
this
.
hidden
=
false
;
}
},
hide
:
function
()
{
if
(
!
this
.
hidden
)
{
// debugger
this
.
list
.
style
.
display
=
'none'
;
this
.
currentIndex
=
0
;
this
.
hidden
=
true
;
}
},
destroy
:
function
()
{
...
...
@@ -479,6 +485,8 @@ Object.assign(HookInput.prototype, {
this
.
input
=
function
input
(
e
)
{
if
(
self
.
hasRemovedEvents
)
return
;
self
.
list
.
show
();
var
inputEvent
=
new
CustomEvent
(
'input.dl'
,
{
detail
:
{
hook
:
self
,
...
...
@@ -488,7 +496,6 @@ Object.assign(HookInput.prototype, {
cancelable
:
true
});
e
.
target
.
dispatchEvent
(
inputEvent
);
self
.
list
.
show
();
}
this
.
keyup
=
function
keyup
(
e
)
{
...
...
@@ -504,6 +511,8 @@ Object.assign(HookInput.prototype, {
}
function
keyEvent
(
e
,
keyEventName
){
self
.
list
.
show
();
var
keyEvent
=
new
CustomEvent
(
keyEventName
,
{
detail
:
{
hook
:
self
,
...
...
@@ -515,7 +524,6 @@ Object.assign(HookInput.prototype, {
cancelable
:
true
});
e
.
target
.
dispatchEvent
(
keyEvent
);
self
.
list
.
show
();
}
this
.
events
=
this
.
events
||
{};
...
...
@@ -573,26 +581,43 @@ require('./window')(function(w){
module
.
exports
=
function
(){
var
currentKey
;
var
currentFocus
;
var
currentIndex
=
0
;
var
isUpArrow
=
false
;
var
isDownArrow
=
false
;
var
removeHighlight
=
function
removeHighlight
(
list
)
{
var
listItems
=
list
.
list
.
querySelectorAll
(
'li:not(.divider)'
);
var
listItems
=
Array
.
prototype
.
slice
.
call
(
list
.
list
.
querySelectorAll
(
'li:not(.divider)'
),
0
);
var
listItemsTmp
=
[];
for
(
var
i
=
0
;
i
<
listItems
.
length
;
i
++
)
{
listItems
[
i
].
classList
.
remove
(
'dropdown-active'
);
var
listItem
=
listItems
[
i
];
listItem
.
classList
.
remove
(
'dropdown-active'
);
if
(
listItem
.
style
.
display
!==
'none'
)
{
listItemsTmp
.
push
(
listItem
);
}
return
listItems
;
}
return
listItemsTmp
;
};
var
setMenuForArrows
=
function
setMenuForArrows
(
list
)
{
var
listItems
=
removeHighlight
(
list
);
if
(
currentIndex
>
0
){
if
(
!
listItems
[
currentIndex
-
1
]){
currentIndex
=
currentIndex
-
1
;
if
(
list
.
currentIndex
>
0
){
if
(
!
listItems
[
list
.
currentIndex
-
1
]){
list
.
currentIndex
=
list
.
currentIndex
-
1
;
}
if
(
listItems
[
currentIndex
-
1
])
{
listItems
[
currentIndex
-
1
].
classList
.
add
(
'dropdown-active'
);
if
(
listItems
[
list
.
currentIndex
-
1
])
{
var
el
=
listItems
[
list
.
currentIndex
-
1
];
var
filterDropdownEl
=
el
.
closest
(
'.filter-dropdown'
);
el
.
classList
.
add
(
'dropdown-active'
);
if
(
filterDropdownEl
)
{
var
filterDropdownBottom
=
filterDropdownEl
.
offsetHeight
;
var
elOffsetTop
=
el
.
offsetTop
-
30
;
if
(
elOffsetTop
>
filterDropdownBottom
)
{
filterDropdownEl
.
scrollTop
=
elOffsetTop
-
filterDropdownBottom
;
console
.
log
(
filterDropdownEl
.
scrollTop
);
}
}
}
}
};
...
...
@@ -601,13 +626,13 @@ require('./window')(function(w){
var
list
=
e
.
detail
.
hook
.
list
;
removeHighlight
(
list
);
list
.
show
();
currentIndex
=
0
;
list
.
currentIndex
=
0
;
isUpArrow
=
false
;
isDownArrow
=
false
;
};
var
selectItem
=
function
selectItem
(
list
)
{
var
listItems
=
removeHighlight
(
list
);
var
currentItem
=
listItems
[
currentIndex
-
1
];
var
currentItem
=
listItems
[
list
.
currentIndex
-
1
];
var
listEvent
=
new
CustomEvent
(
'click.dl'
,
{
detail
:
{
list
:
list
,
...
...
@@ -621,8 +646,8 @@ require('./window')(function(w){
var
keydown
=
function
keydown
(
e
){
var
typedOn
=
e
.
target
;
var
dropdown
=
e
.
detail
.
hook
.
list
;
currentIndex
=
dropdown
.
currentIndex
;
var
list
=
e
.
detail
.
hook
.
list
;
var
currentIndex
=
list
.
currentIndex
;
isUpArrow
=
false
;
isDownArrow
=
false
;
...
...
@@ -654,8 +679,8 @@ require('./window')(function(w){
if
(
isUpArrow
){
currentIndex
--
;
}
if
(
isDownArrow
){
currentIndex
++
;
}
if
(
currentIndex
<
0
){
currentIndex
=
0
;
}
list
.
currentIndex
=
currentIndex
;
setMenuForArrows
(
e
.
detail
.
hook
.
list
);
dropdown
.
currentIndex
=
currentIndex
;
};
w
.
addEventListener
(
'mousedown.dl'
,
mousedown
);
...
...
app/assets/javascripts/droplab/droplab_ajax_filter.js
View file @
ecf08ae1
...
...
@@ -93,6 +93,7 @@ require('../window')(function(w){
self
.
hook
.
list
.
setData
.
call
(
self
.
hook
.
list
,
data
);
}
self
.
notLoading
();
self
.
hook
.
list
.
currentIndex
=
0
;
});
},
...
...
app/assets/javascripts/droplab/droplab_filter.js
View file @
ecf08ae1
...
...
@@ -36,6 +36,7 @@ require('../window')(function(w){
return
filterFunction
(
o
,
value
);
});
list
.
render
(
matches
);
list
.
currentIndex
=
0
;
},
init
:
function
init
(
hookInput
)
{
...
...
spec/features/issues/filtered_search/dropdown_label_spec.rb
View file @
ecf08ae1
...
...
@@ -40,6 +40,16 @@ describe 'Dropdown label', js: true, feature: true do
visit
namespace_project_issues_path
(
project
.
namespace
,
project
)
end
describe
'keyboard navigation'
do
it
'selects label'
do
send_keys_to_filtered_search
(
'label:'
)
filtered_search
.
native
.
send_keys
(
:down
,
:down
,
:enter
)
expect
(
filtered_search
.
value
).
to
eq
(
"label:~
#{
special_label
.
name
}
"
)
end
end
describe
'behavior'
do
it
'opens when the search bar has label:'
do
filtered_search
.
set
(
'label:'
)
...
...
spec/features/issues/filtered_search/search_bar_spec.rb
View file @
ecf08ae1
...
...
@@ -20,6 +20,22 @@ describe 'Search bar', js: true, feature: true do
left_style
.
to_s
.
gsub
(
'left: '
,
''
).
to_f
end
describe
'keyboard navigation'
do
it
'makes item active'
do
filtered_search
.
native
.
send_keys
(
:down
)
page
.
within
'#js-dropdown-hint'
do
expect
(
page
).
to
have_selector
(
'.dropdown-active'
)
end
end
it
'selects item'
do
filtered_search
.
native
.
send_keys
(
:down
,
:down
,
:enter
)
expect
(
filtered_search
.
value
).
to
eq
(
'author:'
)
end
end
describe
'clear search button'
do
it
'clears text'
do
search_text
=
'search_text'
...
...
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