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
Léo-Paul Géneau
gitlab-ce
Commits
3e51c5e6
Commit
3e51c5e6
authored
Jan 02, 2018
by
Martin Wortschack
Committed by
LUKE BENNETT
Jan 02, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clears visual token on second backspace
parent
81dcd8ed
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
15 deletions
+51
-15
app/assets/javascripts/filtered_search/filtered_search_manager.js
...ts/javascripts/filtered_search/filtered_search_manager.js
+27
-15
changelogs/unreleased/38596-fix-backspace-visual-token-clearing.yml
.../unreleased/38596-fix-backspace-visual-token-clearing.yml
+5
-0
spec/features/issues/filtered_search/dropdown_hint_spec.rb
spec/features/issues/filtered_search/dropdown_hint_spec.rb
+5
-0
spec/javascripts/filtered_search/filtered_search_manager_spec.js
...vascripts/filtered_search/filtered_search_manager_spec.js
+14
-0
No files found.
app/assets/javascripts/filtered_search/filtered_search_manager.js
View file @
3e51c5e6
...
...
@@ -127,7 +127,7 @@ class FilteredSearchManager {
this
.
handleInputVisualTokenWrapper
=
this
.
handleInputVisualToken
.
bind
(
this
);
this
.
checkForEnterWrapper
=
this
.
checkForEnter
.
bind
(
this
);
this
.
onClearSearchWrapper
=
this
.
onClearSearch
.
bind
(
this
);
this
.
checkForBackspaceWrapper
=
this
.
checkForBackspace
.
bind
(
this
);
this
.
checkForBackspaceWrapper
=
this
.
checkForBackspace
.
call
(
this
);
this
.
removeSelectedTokenKeydownWrapper
=
this
.
removeSelectedTokenKeydown
.
bind
(
this
);
this
.
unselectEditTokensWrapper
=
this
.
unselectEditTokens
.
bind
(
this
);
this
.
editTokenWrapper
=
this
.
editToken
.
bind
(
this
);
...
...
@@ -180,22 +180,34 @@ class FilteredSearchManager {
this
.
unbindStateEvents
();
}
checkForBackspace
(
e
)
{
// 8 = Backspace Key
// 46 = Delete Key
if
(
e
.
keyCode
===
8
||
e
.
keyCode
===
46
)
{
const
{
lastVisualToken
}
=
gl
.
FilteredSearchVisualTokens
.
getLastVisualTokenBeforeInput
();
checkForBackspace
()
{
let
backspaceCount
=
0
;
// closure for keeping track of the number of backspace keystrokes
return
(
e
)
=>
{
// 8 = Backspace Key
// 46 = Delete Key
if
(
e
.
keyCode
===
8
||
e
.
keyCode
===
46
)
{
const
{
lastVisualToken
}
=
gl
.
FilteredSearchVisualTokens
.
getLastVisualTokenBeforeInput
();
const
{
tokenName
,
tokenValue
}
=
gl
.
DropdownUtils
.
getVisualTokenValues
(
lastVisualToken
);
const
canEdit
=
tokenName
&&
this
.
canEdit
&&
this
.
canEdit
(
tokenName
,
tokenValue
);
if
(
this
.
filteredSearchInput
.
value
===
''
&&
lastVisualToken
&&
canEdit
)
{
backspaceCount
+=
1
;
if
(
backspaceCount
===
2
)
{
backspaceCount
=
0
;
this
.
filteredSearchInput
.
value
=
gl
.
FilteredSearchVisualTokens
.
getLastTokenPartial
();
gl
.
FilteredSearchVisualTokens
.
removeLastTokenPartial
();
}
}
const
{
tokenName
,
tokenValue
}
=
gl
.
DropdownUtils
.
getVisualTokenValues
(
lastVisualToken
);
const
canEdit
=
tokenName
&&
this
.
canEdit
&&
this
.
canEdit
(
tokenName
,
tokenValue
);
if
(
this
.
filteredSearchInput
.
value
===
''
&&
lastVisualToken
&&
canEdit
)
{
this
.
filteredSearchInput
.
value
=
gl
.
FilteredSearchVisualTokens
.
getLastTokenPartial
();
gl
.
FilteredSearchVisualTokens
.
removeLastTokenPartial
();
// Reposition dropdown so that it is aligned with cursor
this
.
dropdownManager
.
updateCurrentDropdownOffset
();
}
else
{
backspaceCount
=
0
;
}
// Reposition dropdown so that it is aligned with cursor
this
.
dropdownManager
.
updateCurrentDropdownOffset
();
}
};
}
checkForEnter
(
e
)
{
...
...
changelogs/unreleased/38596-fix-backspace-visual-token-clearing.yml
0 → 100644
View file @
3e51c5e6
---
title
:
Clears visual token on second backspace
merge_request
:
author
:
Martin Wortschack
type
:
fixed
spec/features/issues/filtered_search/dropdown_hint_spec.rb
View file @
3e51c5e6
...
...
@@ -176,6 +176,7 @@ describe 'Dropdown hint', :js do
it
'reuses existing author text'
do
filtered_search
.
send_keys
(
'author:'
)
filtered_search
.
send_keys
(
:backspace
)
filtered_search
.
send_keys
(
:backspace
)
click_hint
(
'author'
)
expect_tokens
([{
name:
'author'
}])
...
...
@@ -185,6 +186,7 @@ describe 'Dropdown hint', :js do
it
'reuses existing assignee text'
do
filtered_search
.
send_keys
(
'assignee:'
)
filtered_search
.
send_keys
(
:backspace
)
filtered_search
.
send_keys
(
:backspace
)
click_hint
(
'assignee'
)
expect_tokens
([{
name:
'assignee'
}])
...
...
@@ -194,6 +196,7 @@ describe 'Dropdown hint', :js do
it
'reuses existing milestone text'
do
filtered_search
.
send_keys
(
'milestone:'
)
filtered_search
.
send_keys
(
:backspace
)
filtered_search
.
send_keys
(
:backspace
)
click_hint
(
'milestone'
)
expect_tokens
([{
name:
'milestone'
}])
...
...
@@ -203,6 +206,7 @@ describe 'Dropdown hint', :js do
it
'reuses existing label text'
do
filtered_search
.
send_keys
(
'label:'
)
filtered_search
.
send_keys
(
:backspace
)
filtered_search
.
send_keys
(
:backspace
)
click_hint
(
'label'
)
expect_tokens
([{
name:
'label'
}])
...
...
@@ -212,6 +216,7 @@ describe 'Dropdown hint', :js do
it
'reuses existing emoji text'
do
filtered_search
.
send_keys
(
'my-reaction:'
)
filtered_search
.
send_keys
(
:backspace
)
filtered_search
.
send_keys
(
:backspace
)
click_hint
(
'my-reaction'
)
expect_tokens
([{
name:
'my-reaction'
}])
...
...
spec/javascripts/filtered_search/filtered_search_manager_spec.js
View file @
3e51c5e6
...
...
@@ -252,6 +252,7 @@ describe('Filtered Search Manager', () => {
it
(
'
removes last token
'
,
()
=>
{
spyOn
(
gl
.
FilteredSearchVisualTokens
,
'
removeLastTokenPartial
'
).
and
.
callThrough
();
dispatchBackspaceEvent
(
input
,
'
keyup
'
);
dispatchBackspaceEvent
(
input
,
'
keyup
'
);
expect
(
gl
.
FilteredSearchVisualTokens
.
removeLastTokenPartial
).
toHaveBeenCalled
();
});
...
...
@@ -259,6 +260,7 @@ describe('Filtered Search Manager', () => {
it
(
'
sets the input
'
,
()
=>
{
spyOn
(
gl
.
FilteredSearchVisualTokens
,
'
getLastTokenPartial
'
).
and
.
callThrough
();
dispatchDeleteEvent
(
input
,
'
keyup
'
);
dispatchDeleteEvent
(
input
,
'
keyup
'
);
expect
(
gl
.
FilteredSearchVisualTokens
.
getLastTokenPartial
).
toHaveBeenCalled
();
expect
(
input
.
value
).
toEqual
(
'
~bug
'
);
...
...
@@ -276,6 +278,18 @@ describe('Filtered Search Manager', () => {
expect
(
gl
.
FilteredSearchVisualTokens
.
getLastTokenPartial
).
not
.
toHaveBeenCalled
();
expect
(
input
.
value
).
toEqual
(
'
text
'
);
});
it
(
'
does not remove previous token on single backspace press
'
,
()
=>
{
spyOn
(
gl
.
FilteredSearchVisualTokens
,
'
removeLastTokenPartial
'
).
and
.
callThrough
();
spyOn
(
gl
.
FilteredSearchVisualTokens
,
'
getLastTokenPartial
'
).
and
.
callThrough
();
input
.
value
=
'
t
'
;
dispatchDeleteEvent
(
input
,
'
keyup
'
);
expect
(
gl
.
FilteredSearchVisualTokens
.
removeLastTokenPartial
).
not
.
toHaveBeenCalled
();
expect
(
gl
.
FilteredSearchVisualTokens
.
getLastTokenPartial
).
not
.
toHaveBeenCalled
();
expect
(
input
.
value
).
toEqual
(
'
t
'
);
});
});
describe
(
'
removeToken
'
,
()
=>
{
...
...
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