Skip to content

Commit d182b61

Browse files
committed
bug fix
Fix the bug that the filter custom layer could not be closed
1 parent 6ca48b2 commit d182b61

File tree

4 files changed

+63
-18
lines changed

4 files changed

+63
-18
lines changed

CHANGE-LOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@ Vx.x.x(TPL)
77
- Style changes
88
- Dependencies Changes
99

10+
V2.16.2
11+
12+
### Bug Fixes
13+
14+
- Fix the bug that the filter custom layer could not be closed
15+
16+
---
17+
18+
### Bug Fixes
19+
20+
- 修复筛选自定义弹层无法关闭的问题
21+
1022
V2.16.1
1123

1224
### Bug Fixes

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"name": "vue-easytable",
3-
"version": "2.16.1",
3+
"version": "2.16.2",
44
"docVersions": [
55
{
66
"value": "/vue-easytable/",
7-
"label": "2.16.1"
7+
"label": "2.16.2"
88
},
99
{
1010
"value": "/vue-easytable/2.15.0/",

packages/ve-dropdown/src/index.jsx

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,22 @@ export default {
178178
value: function () {
179179
this.init();
180180
},
181+
visible: {
182+
handler(visible) {
183+
const { isControlled, showDropDown, hideDropDown } = this;
184+
// deal after mounted hook
185+
setTimeout(() => {
186+
if (isControlled) {
187+
if (visible) {
188+
showDropDown();
189+
} else {
190+
hideDropDown();
191+
}
192+
}
193+
});
194+
},
195+
immediate: true,
196+
},
181197
},
182198
methods: {
183199
// 初始化
@@ -220,12 +236,10 @@ export default {
220236
hideDropDown() {
221237
this.$emit(EMIT_EVENTS.VISIBLE_CHANGE, false);
222238

223-
if (!this.isControlled) {
224-
setTimeout(() => {
225-
this.internalVisible = false;
226-
this.removeOrEmptyRootPanel();
227-
}, 150);
228-
}
239+
setTimeout(() => {
240+
this.internalVisible = false;
241+
this.removeOrEmptyRootPanel();
242+
}, 150);
229243
},
230244

231245
// remove or emoty root panel
@@ -255,9 +269,7 @@ export default {
255269
this.changDropdownPanelPosition();
256270
}
257271

258-
if (!this.isControlled) {
259-
this.internalVisible = true;
260-
}
272+
this.internalVisible = true;
261273

262274
this.$emit(EMIT_EVENTS.VISIBLE_CHANGE, true);
263275
},
@@ -427,7 +439,7 @@ export default {
427439
},
428440

429441
/*
430-
add root contextmenu panel to element
442+
add root element to element
431443
如果不指定则添加到 body
432444
*/
433445
addRootElementToElement() {

tests/unit/specs/ve-table-header-filter-custom.spec.js

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,15 @@ describe("veTable header filter custom", () => {
4444
},
4545
];
4646

47+
afterEach(() => {
48+
return new Promise((resolve) => {
49+
const poppers = document.querySelector(".ve-dropdown-popper");
50+
poppers && poppers.remove();
51+
52+
resolve();
53+
});
54+
});
55+
4756
it("render", () => {
4857
const wrapper = mount({
4958
render() {
@@ -232,14 +241,26 @@ describe("veTable header filter custom", () => {
232241
expect(wrapper.find(".icon-vet-filter").exists()).toBe(true);
233242

234243
wrapper.find(".ve-table-filter-icon").trigger("click");
235-
await later();
236-
expect(wrapper.find(".ve-dropdown-dd-show").exists()).toBe(true);
244+
// 延迟展示
245+
await later(100);
246+
247+
const showDropdownPopper = document.querySelector(
248+
".ve-dropdown-popper > .ve-dropdown-dd",
249+
);
250+
251+
expect(showDropdownPopper.textContent.length).toBeGreaterThan(1);
252+
253+
const cancelClickEvent = new MouseEvent("click", {
254+
view: window, // window
255+
bubbles: true,
256+
cancelable: true,
257+
});
258+
259+
document
260+
.querySelector(".name-filter-cancel")
261+
.dispatchEvent(cancelClickEvent);
237262

238-
wrapper.find(".name-filter-confirm").trigger("click");
239263
expect(mockFilterFn).toBeCalled();
240264
expect(mockFilterFn).toHaveBeenCalledWith(expect.any(Function));
241-
242-
await later();
243-
expect(wrapper.find(".ve-dropdown-dd-show").exists()).toBe(false);
244265
});
245266
});

0 commit comments

Comments
 (0)