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
2a376050
Commit
2a376050
authored
Jan 14, 2022
by
Florie Guibert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Labels widget - focus first item on search
Changelog: changed
parent
44fda6c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
1 deletion
+25
-1
app/assets/javascripts/vue_shared/components/sidebar/labels_select_widget/dropdown_contents_labels_view.vue
...ar/labels_select_widget/dropdown_contents_labels_view.vue
+12
-1
spec/frontend/vue_shared/components/sidebar/labels_select_widget/dropdown_contents_labels_view_spec.js
...abels_select_widget/dropdown_contents_labels_view_spec.js
+13
-0
No files found.
app/assets/javascripts/vue_shared/components/sidebar/labels_select_widget/dropdown_contents_labels_view.vue
View file @
2a376050
...
...
@@ -84,6 +84,14 @@ export default {
showNoMatchingResultsMessage
()
{
return
Boolean
(
this
.
searchKey
)
&&
this
.
visibleLabels
.
length
===
0
;
},
shouldHighlighFirstItem
()
{
return
this
.
searchKey
!==
''
&&
this
.
visibleLabels
.
length
>
0
;
},
},
updated
()
{
if
(
this
.
shouldHighlighFirstItem
)
{
this
.
$refs
.
labelItem
[
0
]?.
$el
?.
firstChild
?.
focus
();
}
},
methods
:
{
isLabelSelected
(
label
)
{
...
...
@@ -143,11 +151,14 @@ export default {
/>
<template
v-else
>
<gl-dropdown-item
v-for=
"label in visibleLabels"
v-for=
"(label, index) in visibleLabels"
ref=
"labelItem"
:key=
"label.id"
:is-checked=
"isLabelSelected(label)"
:is-check-centered=
"true"
:is-check-item=
"true"
:active=
"shouldHighlighFirstItem && index === 0"
active-class=
"is-focused"
data-testid=
"labels-list"
@
click.native.capture.stop=
"handleLabelClick(label)"
>
...
...
spec/frontend/vue_shared/components/sidebar/labels_select_widget/dropdown_contents_labels_view_spec.js
View file @
2a376050
...
...
@@ -110,6 +110,19 @@ describe('DropdownContentsLabelsView', () => {
});
});
it
(
'
first item is active when search is not empty
'
,
async
()
=>
{
createComponent
({
queryHandler
:
jest
.
fn
().
mockResolvedValue
(
workspaceLabelsQueryResponse
),
searchKey
:
'
Label
'
,
});
await
makeObserverAppear
();
await
waitForPromises
();
await
nextTick
();
expect
(
findLabelsList
().
exists
()).
toBe
(
true
);
expect
(
findFirstLabel
().
attributes
(
'
active
'
)).
toBe
(
'
true
'
);
});
it
(
'
when search returns 0 results
'
,
async
()
=>
{
createComponent
({
queryHandler
:
jest
.
fn
().
mockResolvedValue
({
...
...
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