Skip to content

Commit 69e868c

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 1e271bc commit 69e868c

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
@@ -1018,8 +1018,16 @@ jQuery(function() {
10181018
if (elt.matches(item.selector)) {
10191019
const instance = bootstrap[item.component].getInstance(elt);
10201020
if (instance) {
1021-
if (instance._isShown && instance._isShown()) {
1022-
instance.hide();
1021+
// _isShown is a boolean for Modal components and a function for others.
1022+
if (instance._isShown) {
1023+
if (typeof instance._isShown === 'function') {
1024+
if (instance._isShown()) {
1025+
instance.hide();
1026+
}
1027+
}
1028+
else {
1029+
instance.hide();
1030+
}
10231031
}
10241032

10251033
let interval;

0 commit comments

Comments
 (0)