Skip to content

Commit 6dbae2a

Browse files
author
Denis Korablev
committed
fix: fix conflict with filtering operation
1 parent ef6f03d commit 6dbae2a

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

packages/style/ve-table.less

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
height: 16px;
9090
margin-left: 5px;
9191
color: @ve-table-sort-icon-default-color;
92-
cursor: pointer;
92+
pointer-events: none;
9393
.ve-table-sort-icon {
9494
position: absolute;
9595
display: block;
@@ -108,6 +108,10 @@
108108
}
109109
}
110110

111+
&.ve-table-sortable-column {
112+
cursor: pointer;
113+
}
114+
111115
/* filter */
112116
.ve-table-filter {
113117
display: inline-block;

packages/ve-table/src/header/header-th.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,10 @@ export default {
604604
click: (e) => {
605605
this.cellClick(e, click);
606606

607-
if (this.isSortableCloumn) {
607+
if (
608+
this.isSortableCloumn &&
609+
e.target instanceof HTMLTableCellElement
610+
) {
608611
this.sortChange();
609612
}
610613
},

tests/unit/specs/__snapshots__/ve-table-header-sort.spec.js.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ exports[`veTable header sort render multiple field sort 1`] = `
1616
<thead class="ve-table-fixed-header ve-table-header">
1717
<tr class="ve-table-header-tr">
1818
<th rowspan="1" colspan="1" class="ve-table-header-th" style="text-align: left; top: 0px;">Name</th>
19-
<th rowspan="1" colspan="1" class="ve-table-header-th" style="text-align: center; top: 0px;">Age<span class="ve-table-sort"><i class="ve-icon iconfont-vet icon-vet-sort-top-arrow ve-table-sort-icon ve-table-sort-icon-top"></i><i class="ve-icon iconfont-vet icon-vet-sort-bottom-arrow ve-table-sort-icon ve-table-sort-icon-bottom"></i></span></th>
20-
<th rowspan="1" colspan="1" class="ve-table-header-th" style="text-align: center; top: 0px;">Weight(kg)<span class="ve-table-sort"><i class="ve-icon iconfont-vet icon-vet-sort-top-arrow ve-table-sort-icon ve-table-sort-icon-top active"></i><i class="ve-icon iconfont-vet icon-vet-sort-bottom-arrow ve-table-sort-icon ve-table-sort-icon-bottom"></i></span></th>
19+
<th rowspan="1" colspan="1" class="ve-table-header-th ve-table-sortable-column" style="text-align: center; top: 0px;">Age<span class="ve-table-sort"><i class="ve-icon iconfont-vet icon-vet-sort-top-arrow ve-table-sort-icon ve-table-sort-icon-top"></i><i class="ve-icon iconfont-vet icon-vet-sort-bottom-arrow ve-table-sort-icon ve-table-sort-icon-bottom"></i></span></th>
20+
<th rowspan="1" colspan="1" class="ve-table-header-th ve-table-sortable-column" style="text-align: center; top: 0px;">Weight(kg)<span class="ve-table-sort"><i class="ve-icon iconfont-vet icon-vet-sort-top-arrow ve-table-sort-icon ve-table-sort-icon-top active"></i><i class="ve-icon iconfont-vet icon-vet-sort-bottom-arrow ve-table-sort-icon ve-table-sort-icon-bottom"></i></span></th>
2121
<th rowspan="1" colspan="1" class="ve-table-header-th" style="text-align: center; top: 0px;">Hobby</th>
2222
<th rowspan="1" colspan="1" class="ve-table-header-th ve-table-last-column" style="text-align: left; top: 0px;">Address</th>
2323
</tr>
@@ -96,8 +96,8 @@ exports[`veTable header sort render single field sort 1`] = `
9696
<thead class="ve-table-fixed-header ve-table-header">
9797
<tr class="ve-table-header-tr">
9898
<th rowspan="1" colspan="1" class="ve-table-header-th" style="text-align: left; top: 0px;">Name</th>
99-
<th rowspan="1" colspan="1" class="ve-table-header-th" style="text-align: center; top: 0px;">Age<span class="ve-table-sort"><i class="ve-icon iconfont-vet icon-vet-sort-top-arrow ve-table-sort-icon ve-table-sort-icon-top"></i><i class="ve-icon iconfont-vet icon-vet-sort-bottom-arrow ve-table-sort-icon ve-table-sort-icon-bottom"></i></span></th>
100-
<th rowspan="1" colspan="1" class="ve-table-header-th" style="text-align: center; top: 0px;">Weight(kg)<span class="ve-table-sort"><i class="ve-icon iconfont-vet icon-vet-sort-top-arrow ve-table-sort-icon ve-table-sort-icon-top active"></i><i class="ve-icon iconfont-vet icon-vet-sort-bottom-arrow ve-table-sort-icon ve-table-sort-icon-bottom"></i></span></th>
99+
<th rowspan="1" colspan="1" class="ve-table-header-th ve-table-sortable-column" style="text-align: center; top: 0px;">Age<span class="ve-table-sort"><i class="ve-icon iconfont-vet icon-vet-sort-top-arrow ve-table-sort-icon ve-table-sort-icon-top"></i><i class="ve-icon iconfont-vet icon-vet-sort-bottom-arrow ve-table-sort-icon ve-table-sort-icon-bottom"></i></span></th>
100+
<th rowspan="1" colspan="1" class="ve-table-header-th ve-table-sortable-column" style="text-align: center; top: 0px;">Weight(kg)<span class="ve-table-sort"><i class="ve-icon iconfont-vet icon-vet-sort-top-arrow ve-table-sort-icon ve-table-sort-icon-top active"></i><i class="ve-icon iconfont-vet icon-vet-sort-bottom-arrow ve-table-sort-icon ve-table-sort-icon-bottom"></i></span></th>
101101
<th rowspan="1" colspan="1" class="ve-table-header-th" style="text-align: center; top: 0px;">Hobby</th>
102102
<th rowspan="1" colspan="1" class="ve-table-header-th ve-table-last-column" style="text-align: left; top: 0px;">Address</th>
103103
</tr>

tests/unit/specs/ve-table-header-sort.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ describe("veTable header sort", () => {
217217
.exists(),
218218
).toBe(true);
219219

220-
thEls.at(1).find(".ve-table-sort").trigger("click");
220+
thEls.at(1).find(".ve-table-sortable-column").trigger("click");
221221

222222
await later();
223223

@@ -361,7 +361,7 @@ describe("veTable header sort", () => {
361361
.exists(),
362362
).toBe(true);
363363

364-
thEls.at(1).find(".ve-table-sort").trigger("click");
364+
thEls.at(1).find(".ve-table-sortable-column").trigger("click");
365365

366366
await later();
367367

@@ -425,7 +425,7 @@ describe("veTable header sort", () => {
425425

426426
const thEls = wrapper.findAll(".ve-table-header-tr th");
427427

428-
thEls.at(1).find(".ve-table-sort").trigger("click");
428+
thEls.at(1).find(".ve-table-sortable-column").trigger("click");
429429

430430
await later();
431431

@@ -434,7 +434,7 @@ describe("veTable header sort", () => {
434434
weight: "",
435435
});
436436

437-
thEls.at(1).find(".ve-table-sort").trigger("click");
437+
thEls.at(1).find(".ve-table-sortable-column").trigger("click");
438438

439439
await later();
440440

0 commit comments

Comments
 (0)