Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
3e51c5e6
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3e51c5e6
编写于
1月 02, 2018
作者:
M
Martin Wortschack
提交者:
LUKE BENNETT
1月 02, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clears visual token on second backspace
上级
81dcd8ed
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
51 addition
and
15 deletion
+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
未找到文件。
app/assets/javascripts/filtered_search/filtered_search_manager.js
浏览文件 @
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
浏览文件 @
3e51c5e6
---
title
:
Clears visual token on second backspace
merge_request
:
author
:
Martin Wortschack
type
:
fixed
spec/features/issues/filtered_search/dropdown_hint_spec.rb
浏览文件 @
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
浏览文件 @
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
'
,
()
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录