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
13986d5b
Commit
13986d5b
authored
Jan 19, 2022
by
Florie Guibert
Committed by
Natalia Tepluhina
Jan 19, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Labels widget - focus first item on search
Changelog: changed
parent
ddf15292
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
1 deletion
+50
-1
app/assets/javascripts/vue_shared/components/sidebar/labels_select_widget/dropdown_contents.vue
...onents/sidebar/labels_select_widget/dropdown_contents.vue
+5
-0
app/assets/javascripts/vue_shared/components/sidebar/labels_select_widget/dropdown_contents_labels_view.vue
...ar/labels_select_widget/dropdown_contents_labels_view.vue
+11
-1
app/assets/javascripts/vue_shared/components/sidebar/labels_select_widget/dropdown_header.vue
...mponents/sidebar/labels_select_widget/dropdown_header.vue
+1
-0
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
spec/support/shared_examples/features/sidebar/sidebar_labels_shared_examples.rb
...amples/features/sidebar/sidebar_labels_shared_examples.rb
+20
-0
No files found.
app/assets/javascripts/vue_shared/components/sidebar/labels_select_widget/dropdown_contents.vue
View file @
13986d5b
...
...
@@ -179,6 +179,9 @@ export default {
this
.
searchKey
=
''
;
this
.
setFocus
();
},
selectFirstItem
()
{
this
.
$refs
.
dropdownContentsView
.
selectFirstItem
();
},
},
};
</
script
>
...
...
@@ -204,11 +207,13 @@ export default {
@
toggleDropdownContentsCreateView=
"toggleDropdownContent"
@
closeDropdown=
"$emit('closeDropdown')"
@
input=
"debouncedSearchKeyUpdate"
@
searchEnter=
"selectFirstItem"
/>
</
template
>
<
template
#default
>
<component
:is=
"dropdownContentsView"
ref=
"dropdownContentsView"
v-model=
"localSelectedLabels"
:search-key=
"searchKey"
:allow-multiselect=
"allowMultiselect"
...
...
app/assets/javascripts/vue_shared/components/sidebar/labels_select_widget/dropdown_contents_labels_view.vue
View file @
13986d5b
...
...
@@ -84,6 +84,9 @@ export default {
showNoMatchingResultsMessage
()
{
return
Boolean
(
this
.
searchKey
)
&&
this
.
visibleLabels
.
length
===
0
;
},
shouldHighlightFirstItem
()
{
return
this
.
searchKey
!==
''
&&
this
.
visibleLabels
.
length
>
0
;
},
},
methods
:
{
isLabelSelected
(
label
)
{
...
...
@@ -128,6 +131,11 @@ export default {
onDropdownAppear
()
{
this
.
isVisible
=
true
;
},
selectFirstItem
()
{
if
(
this
.
shouldHighlightFirstItem
)
{
this
.
handleLabelClick
(
this
.
visibleLabels
[
0
]);
}
},
},
};
</
script
>
...
...
@@ -143,11 +151,13 @@ export default {
/>
<template
v-else
>
<gl-dropdown-item
v-for=
"
label
in visibleLabels"
v-for=
"
(label, index)
in visibleLabels"
:key=
"label.id"
:is-checked=
"isLabelSelected(label)"
:is-check-centered=
"true"
:is-check-item=
"true"
:active=
"shouldHighlightFirstItem && index === 0"
active-class=
"is-focused"
data-testid=
"labels-list"
@
click.native.capture.stop=
"handleLabelClick(label)"
>
...
...
app/assets/javascripts/vue_shared/components/sidebar/labels_select_widget/dropdown_header.vue
View file @
13986d5b
...
...
@@ -83,6 +83,7 @@ export default {
data-qa-selector=
"dropdown_input_field"
data-testid=
"dropdown-input-field"
@
input=
"$emit('input', $event)"
@
keydown.enter=
"$emit('searchEnter', $event)"
/>
</div>
</
template
>
spec/frontend/vue_shared/components/sidebar/labels_select_widget/dropdown_contents_labels_view_spec.js
View file @
13986d5b
...
...
@@ -110,6 +110,19 @@ describe('DropdownContentsLabelsView', () => {
});
});
it
(
'
first item is highlighted 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
({
...
...
spec/support/shared_examples/features/sidebar/sidebar_labels_shared_examples.rb
View file @
13986d5b
...
...
@@ -47,6 +47,26 @@ RSpec.shared_examples 'labels sidebar widget' do
end
end
it
'adds first label by pressing enter when search'
do
within
(
labels_widget
)
do
page
.
within
(
'[data-testid="value-wrapper"]'
)
do
expect
(
page
).
not_to
have_content
(
development
.
name
)
end
fill_in
'Search'
,
with:
'Devel'
sleep
1
expect
(
page
.
all
(
:css
,
'[data-testid="dropdown-content"] .gl-new-dropdown-item'
).
length
).
to
eq
(
1
)
find_field
(
'Search'
).
native
.
send_keys
(
:enter
)
click_button
'Close'
wait_for_requests
page
.
within
(
'[data-testid="value-wrapper"]'
)
do
expect
(
page
).
to
have_content
(
development
.
name
)
end
end
end
it
'escapes XSS when viewing issuable labels'
do
page
.
within
(
labels_widget
)
do
expect
(
page
).
to
have_content
'<script>alert("xss");</script>'
...
...
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