Skip to content

Commit daff6af

Browse files
committed
Properly check bootstrap modal state during cleanup
This resolves the following JavaScript error that occurs when clicking links within modal dialogs, such as in the Permalink modal: instance._isShown is not a function
1 parent 3f9c02d commit daff6af

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

share/static/js/util.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,8 +1049,16 @@ jQuery(function() {
10491049
if (elt.matches(item.selector)) {
10501050
const instance = bootstrap[item.component].getInstance(elt);
10511051
if (instance) {
1052-
if (instance._isShown && instance._isShown()) {
1053-
instance.hide();
1052+
// _isShown is a boolean for Modal components and a function for others.
1053+
if (instance._isShown) {
1054+
if (typeof instance._isShown === 'function') {
1055+
if (instance._isShown()) {
1056+
instance.hide();
1057+
}
1058+
}
1059+
else {
1060+
instance.hide();
1061+
}
10541062
}
10551063

10561064
let interval;

0 commit comments

Comments
 (0)