This bug applies to Meta Stack Overflow and Meta Stack Exchange (possibly others) but not to Stack Overflow (possibly others). The JS sources for these are always a bit different, with the Metas having a more up-to-date version, if I recall correctly.
Flag or vote to close a post.
Expected result: the flag dialog closes, you get the familiar “Thanks, we’ll take a look at it” toast notification.
But instead, the flag or close vote dialog doesn’t close, the toast notification does not appear, an error is thrown. The flag or close vote still goes through.
Retract the flag or close vote again.
Expected result: the flag dialog closes, you get the familiar “Your vote is retracted” toast notification.
But instead, all the symptoms of Case 1 emerge, and a loading GIF is displayed next to the Retract flag button. The retraction still goes through.
The error is this: “Uncaught
TypeError: can’t access property "
undefined” at stub.en.js:1:37708.
The error occurs inside
StackExchange.helpers.showToast, at part of an expression that looks like
o.useRawHtml || (e = this.htmlEncode(e)), after it’s called from an obfuscated function in
(...t) => e()(...t).
e() === StackExchange.helpers.showToast holds true.
It’s a bit difficult to backtrack through the obfuscated code, but it is clear, here, that
this.htmlEncode was supposed to refer to
StackExchange.helpers.htmlEncode, but the
showToast isn’t bound and there’s no way for
e()(...t) to be called with any non-undefined
Other instances where
this is used inside the
StackExchange.helpers object appear to work correctly, and usually
StackExchange.helpers is used directly instead of
this; that would fix the bug here as well:
o.useRawHtml || (e = StackExchange.helpers.htmlEncode(e)) instead of
o.useRawHtml || (e = this.htmlEncode(e)).
I will do some more debugging — almost certainly the problem is more extensive, but this bug report should be enough for Stack Exchange to fix this.
The modals not being dismissed automatically appears to be specific to questions. Inline error pop-ups seem to work correctly. Toast notifications shown when casting or retracting comment flags seem to work correctly. I don’t know if the “Please consider adding a comment if you think this post can be improved.” toast works correctly.
showBannerMessage all use
this.showErrorMessage. It’s worth checking if these refer to the correct
this as well.