Skip to content

Commit dce36f4

Browse files
committed
refactor: 增加 hideCallback 回调
1 parent c45b44c commit dce36f4

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/BootstrapBlazor/wwwroot/modules/base-popover.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ const Popover = {
1414
isDisabled: () => {
1515
return isDisabled(el) || isDisabled(el.parentNode) || isDisabled(el.querySelector('.form-control'))
1616
},
17-
initCallback: null
17+
initCallback: null,
18+
hideCallback: null
1819
},
19-
...config || {}
20+
...(config ?? {})
2021
}
2122
const createPopover = () => {
2223
if (!popover.isDisabled()) {
@@ -69,6 +70,12 @@ const Popover = {
6970
}
7071
}
7172

73+
popover.triggerHideCallback = () => {
74+
if (popover.hideCallback) {
75+
popover.hideCallback();
76+
};
77+
}
78+
7279
if (popover.isPopover) {
7380
popover.hasDisplayNone = false;
7481

@@ -112,6 +119,8 @@ const Popover = {
112119
popover.popover.tip.classList.remove('show');
113120
el.classList.remove('show');
114121
el.append(popover.toggleMenu);
122+
123+
popover.triggerHideCallback();
115124
}
116125

117126
const active = e => {
@@ -176,6 +185,7 @@ const Popover = {
176185
}
177186

178187
EventHandler.on(el, 'show.bs.dropdown', show)
188+
EventHandler.on(el, 'hide.bs.dropdown', popover.triggerHideCallback)
179189

180190
popover.popover = bootstrap.Dropdown.getOrCreateInstance(popover.toggleElement);
181191
}
@@ -200,6 +210,7 @@ const Popover = {
200210
}
201211
else {
202212
EventHandler.off(popover.el, 'show.bs.dropdown')
213+
EventHandler.off(popover.el, 'hide.bs.dropdown')
203214
}
204215
}
205216
}

0 commit comments

Comments
 (0)