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
c3a2d417
Commit
c3a2d417
authored
Aug 27, 2019
by
Cr
Committed by
hetech
Aug 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Table: not trigger sort-change event when mounted (#17113)
parent
747334f0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
24 deletions
+35
-24
packages/table/src/store/index.js
packages/table/src/store/index.js
+3
-3
test/unit/specs/table.spec.js
test/unit/specs/table.spec.js
+32
-21
No files found.
packages/table/src/store/index.js
View file @
c3a2d417
...
...
@@ -68,13 +68,13 @@ Watcher.prototype.mutations = {
},
sort
(
states
,
options
)
{
const
{
prop
,
order
}
=
options
;
const
{
prop
,
order
,
init
}
=
options
;
if
(
prop
)
{
const
column
=
arrayFind
(
states
.
columns
,
column
=>
column
.
property
===
prop
);
if
(
column
)
{
column
.
order
=
order
;
this
.
updateSort
(
column
,
prop
,
order
);
this
.
commit
(
'
changeSortCondition
'
);
this
.
commit
(
'
changeSortCondition
'
,
{
init
}
);
}
}
},
...
...
@@ -89,7 +89,7 @@ Watcher.prototype.mutations = {
const
ingore
=
{
filter
:
true
};
this
.
execQuery
(
ingore
);
if
(
!
options
||
!
options
.
silent
)
{
if
(
!
options
||
!
(
options
.
silent
||
options
.
init
)
)
{
this
.
table
.
$emit
(
'
sort-change
'
,
{
column
,
prop
,
...
...
test/unit/specs/table.spec.js
View file @
c3a2d417
...
...
@@ -555,6 +555,38 @@ describe('Table', () => {
done
();
},
DELAY
);
});
it
(
'
sort-change
'
,
async
()
=>
{
const
vm
=
createVue
({
template
:
`
<el-table ref="table" :data="testData" :default-sort = "{prop: 'runtime', order: 'ascending'}">
<el-table-column prop="name" />
<el-table-column prop="release" />
<el-table-column prop="director" />
<el-table-column prop="runtime" sortable/>
</el-table>
`
,
created
()
{
this
.
testData
=
getTestData
();
},
data
()
{
return
{
testData
:
this
.
testData
};
}
});
const
spy
=
sinon
.
spy
();
vm
.
$refs
.
table
.
$on
(
'
sort-change
'
,
spy
);
await
waitImmediate
();
expect
(
spy
.
notCalled
).
to
.
be
.
true
;
// not emit when mounted
const
elm
=
vm
.
$el
.
querySelector
(
'
.caret-wrapper
'
);
elm
.
click
();
await
waitImmediate
();
expect
(
spy
.
calledOnce
).
to
.
be
.
true
;
destroyVM
(
vm
);
});
});
describe
(
'
column attributes
'
,
()
=>
{
...
...
@@ -1144,27 +1176,6 @@ describe('Table', () => {
},
DELAY
);
},
DELAY
);
});
it
(
'
sort-change
'
,
done
=>
{
let
result
;
const
vm
=
createTable
(
'
sortable="custom"
'
,
''
,
''
,
''
,
{
methods
:
{
sortChange
(...
args
)
{
result
=
args
;
}
}
},
'
@sort-change="sortChange"
'
);
setTimeout
(
_
=>
{
const
elm
=
vm
.
$el
.
querySelector
(
'
.caret-wrapper
'
);
elm
.
click
();
setTimeout
(
_
=>
{
expect
(
result
).
to
.
exist
;
destroyVM
(
vm
);
done
();
},
DELAY
);
},
DELAY
);
});
});
describe
(
'
click sortable column
'
,
()
=>
{
...
...
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