Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
c7d3de95
Commit
c7d3de95
authored
Nov 15, 2017
by
wacky6.AriesMBP
Committed by
杨奕
Nov 15, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
input: fix focus
parent
28849840
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
packages/input/src/input.vue
packages/input/src/input.vue
+5
-3
test/unit/specs/message-box.spec.js
test/unit/specs/message-box.spec.js
+18
-3
No files found.
packages/input/src/input.vue
View file @
c7d3de95
...
...
@@ -77,7 +77,6 @@
</template>
<
script
>
import
emitter
from
'
element-ui/src/mixins/emitter
'
;
import
Focus
from
'
element-ui/src/mixins/focus
'
;
import
Migrating
from
'
element-ui/src/mixins/migrating
'
;
import
calcTextareaHeight
from
'
./calcTextareaHeight
'
;
import
merge
from
'
element-ui/src/utils/merge
'
;
...
...
@@ -87,7 +86,7 @@
componentName
:
'
ElInput
'
,
mixins
:
[
emitter
,
Focus
(
'
input
'
),
Migrating
],
mixins
:
[
emitter
,
Migrating
],
inject
:
{
elForm
:
{
...
...
@@ -183,6 +182,9 @@
},
methods
:
{
focus
()
{
(
this
.
$refs
.
input
||
this
.
$refs
.
textarea
).
focus
();
},
getMigratingConfig
()
{
return
{
props
:
{
...
...
@@ -201,7 +203,7 @@
}
},
inputSelect
()
{
this
.
$refs
.
input
.
select
();
(
this
.
$refs
.
input
||
this
.
$refs
.
textarea
)
.
select
();
},
resizeTextarea
()
{
if
(
this
.
$isServer
)
return
;
...
...
test/unit/specs/message-box.spec.js
View file @
c7d3de95
...
...
@@ -99,15 +99,30 @@ describe('MessageBox', () => {
inputErrorMessage
:
'
validation failed
'
});
setTimeout
(()
=>
{
expect
(
document
.
querySelector
(
'
.el-message-box__input
'
)).
to
.
exist
;
const
messageBox
=
document
.
querySelector
(
'
.el-message-box__wrapper
'
).
__vue__
.
$parent
;
expect
(
messageBox
.
$el
.
querySelector
(
'
.el-message-box__input
'
)).
to
.
exist
;
const
haveFocus
=
messageBox
.
$el
.
querySelector
(
'
input
'
).
isSameNode
(
document
.
activeElement
);
expect
(
haveFocus
).
to
.
true
;
messageBox
.
inputValue
=
'
no
'
;
setTimeout
(()
=>
{
expect
(
document
.
querySelector
(
'
.el-message-box__errormsg
'
)
expect
(
messageBox
.
$el
.
querySelector
(
'
.el-message-box__errormsg
'
)
.
textContent
).
to
.
equal
(
'
validation failed
'
);
done
();
},
100
);
},
200
);
},
700
);
});
it
(
'
prompt: focus on textarea
'
,
done
=>
{
MessageBox
.
prompt
(
'
这是一段内容
'
,
{
inputType
:
'
textarea
'
,
title
:
'
标题名称
'
});
setTimeout
(()
=>
{
const
messageBox
=
document
.
querySelector
(
'
.el-message-box__wrapper
'
).
__vue__
.
$parent
;
const
haveFocus
=
messageBox
.
$el
.
querySelector
(
'
textarea
'
).
isSameNode
(
document
.
activeElement
);
expect
(
haveFocus
).
to
.
true
;
done
();
},
700
);
});
describe
(
'
custom validator
'
,
()
=>
{
...
...
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