Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
5b87cd07
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
5b87cd07
编写于
11月 05, 2019
作者:
M
Mouad Debbar
提交者:
GitHub
11月 05, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix bug where Enter doesn't add new line in multi-line fields (#13630)
上级
fcd8a218
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
62 addition
and
3 deletion
+62
-3
lib/web_ui/lib/src/engine/text_editing/input_type.dart
lib/web_ui/lib/src/engine/text_editing/input_type.dart
+6
-0
lib/web_ui/lib/src/engine/text_editing/text_editing.dart
lib/web_ui/lib/src/engine/text_editing/text_editing.dart
+2
-1
lib/web_ui/test/text_editing_test.dart
lib/web_ui/test/text_editing_test.dart
+54
-2
未找到文件。
lib/web_ui/lib/src/engine/text_editing/input_type.dart
浏览文件 @
5b87cd07
...
...
@@ -59,6 +59,9 @@ abstract class EngineInputType {
/// <https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/inputmode>.
String
get
inputmodeAttribute
;
/// Whether this input type allows the "Enter" key to submit the input action.
bool
get
submitActionOnEnter
=>
true
;
/// Create the appropriate DOM element for this input type.
html
.
HtmlElement
createDomElement
()
=>
html
.
InputElement
();
...
...
@@ -124,6 +127,9 @@ class MultilineInputType extends EngineInputType {
@override
final
String
inputmodeAttribute
=
null
;
@override
bool
get
submitActionOnEnter
=>
false
;
@override
html
.
HtmlElement
createDomElement
()
=>
html
.
TextAreaElement
();
}
lib/web_ui/lib/src/engine/text_editing/text_editing.dart
浏览文件 @
5b87cd07
...
...
@@ -437,7 +437,8 @@ class TextEditingElement {
}
void
_maybeSendAction
(
html
.
KeyboardEvent
event
)
{
if
(
event
.
keyCode
==
_kReturnKeyCode
)
{
if
(
_inputConfiguration
.
inputType
.
submitActionOnEnter
&&
event
.
keyCode
==
_kReturnKeyCode
)
{
event
.
preventDefault
();
_onAction
(
_inputConfiguration
.
inputAction
);
}
...
...
lib/web_ui/test/text_editing_test.dart
浏览文件 @
5b87cd07
...
...
@@ -13,6 +13,9 @@ import 'package:test/test.dart';
import
'matchers.dart'
;
/// The `keyCode` of the "Enter" key.
const
int
_kReturnKeyCode
=
13
;
const
MethodCodec
codec
=
JSONMethodCodec
();
TextEditingElement
editingElement
;
...
...
@@ -250,10 +253,41 @@ void main() {
// No input action so far.
expect
(
lastInputAction
,
isNull
);
dispatchKeyboardEvent
(
editingElement
.
domElement
,
'keydown'
,
keyCode:
13
);
dispatchKeyboardEvent
(
editingElement
.
domElement
,
'keydown'
,
keyCode:
_kReturnKeyCode
,
);
expect
(
lastInputAction
,
'TextInputAction.done'
);
});
test
(
'Does not trigger input action in multi-line mode'
,
()
{
final
InputConfiguration
config
=
InputConfiguration
(
inputType:
EngineInputType
.
multiline
,
obscureText:
false
,
inputAction:
'TextInputAction.done'
,
);
editingElement
.
enable
(
config
,
onChange:
trackEditingState
,
onAction:
trackInputAction
,
);
// No input action so far.
expect
(
lastInputAction
,
isNull
);
final
KeyboardEvent
event
=
dispatchKeyboardEvent
(
editingElement
.
domElement
,
'keydown'
,
keyCode:
_kReturnKeyCode
,
);
// Still no input action.
expect
(
lastInputAction
,
isNull
);
// And default behavior of keyboard event shouldn't have been prevented.
expect
(
event
.
defaultPrevented
,
isFalse
);
});
group
(
'[persistent mode]'
,
()
{
test
(
'Does not accept dom elements of a wrong type'
,
()
{
// A regular <span> shouldn't be accepted.
...
...
@@ -883,7 +917,7 @@ void main() {
dispatchKeyboardEvent
(
textEditing
.
editingElement
.
domElement
,
'keydown'
,
keyCode:
13
,
keyCode:
_kReturnKeyCode
,
);
expect
(
spy
.
messages
,
hasLength
(
1
));
...
...
@@ -894,6 +928,24 @@ void main() {
<
dynamic
>[
clientId
,
'TextInputAction.next'
],
);
});
test
(
'does not send input action in multi-line mode'
,
()
{
showKeyboard
(
inputType:
'multiline'
,
inputAction:
'TextInputAction.next'
,
);
final
KeyboardEvent
event
=
dispatchKeyboardEvent
(
textEditing
.
editingElement
.
domElement
,
'keydown'
,
keyCode:
_kReturnKeyCode
,
);
// No input action and no platform message have been sent.
expect
(
spy
.
messages
,
isEmpty
);
// And default behavior of keyboard event shouldn't have been prevented.
expect
(
event
.
defaultPrevented
,
isFalse
);
});
});
group
(
'EditingState'
,
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录