This just started: I went to add a snippet to an answer on SO, typed it in, clicked the Insert button, and...nothing. No error in the console, but nothing inserted in the question. Earlier today they were working fine. Using Chrome FWIW. No proxy.

Update: Still not working Saturday evening (UK time). And I can confirm what they say over on the meta.SO bug report, that if you click outside of the popup window instead of pressing the insert button, the code does get inserted correctly. So there's a workaround.

  • MEEEE TOOOOOOO. – nicael Oct 3 '14 at 17:02
  • And not only on SO. Everywhere where Snippets Editor was implemented. – nicael Oct 3 '14 at 17:06
  • 4
    SO bug report, and Code Review bug report. There are probably others. – gunr2171 Oct 4 '14 at 16:00
  • 1
    @gunr2171: Thanks. I was wondering why it was so quiet here. Makes sense most of the attention would be on meta.SO and meta.CR. I figured if it happened more than one place (I checked if it was happening here, you see), this was the place to post it. :-) – T.J. Crowder Oct 4 '14 at 16:35

Sorry for the delay in fixing this, I was on vacation. Thanks for bringing this bug up. I've patched the issue and the fix will be live in the next production release (meta: > rev 2014.10.7.2635, q&a: > rev 2014.10.7.1918).

  • 1
    Welcome back! :-) – T.J. Crowder Oct 8 '14 at 16:16
  • 1
    Thanks @T.J.Crowder - sorry again for the delay in fixing this bug. I'm mad that I introduced it before vacation but stuff happens. – Haney Oct 8 '14 at 16:17
  • Yay for @Haney! There's been quite the discussion during your holidays :) – DavidG Oct 8 '14 at 16:31

This is a simple bug in the snippet editor JS.

The "Insert into Post" button is set up to delegate any clicks on it to the "lightbox" element surrounding the snippet editor dialog, like this:

var pluginInsertButton = $('<input type="button" value="' + "Insert into Post" + '" style="margin-left: 5px;"></input>').click(function () {

Alas, however, the lightbox doesn't actually react to click events, but only to mousedown events:

$("#lightbox").mousedown(function () {
    var div = $(this).next("div").find(".popup");
    var snippet = div.data("_snippet");
    var state = snippet.save();
    // Check if we have anything to do
    if (state.html == '' && state.css == '' && state.js == '') {
    var result = markdownGenerator(state);
    window.addSnippetToEditor(result, result);

Normally, a real mouse click will generate both a mousedown and a click event, but the delegated click event will not come with an associated mousedown event, and so nothing happens.

The straightforward fix would be to replace the line $("#lightbox").click(); in the code with $("#lightbox").mousedown();.

In the mean time, you can work around the issue by running the following JavaScript code in your browser's developer console:

$(document).on( 'click', '#lightbox', function () { $(this).mousedown() } )

This workaround is now included in the Stack Overflow Unofficial Patch user script, as of v1.24.

  • 1
    Well, the workaround of just clicking outside the frame works just fine, too. Quite surprised to see this bug lasting so long, but then it is the weekend. – T.J. Crowder Oct 5 '14 at 21:21
  • 1
    I think I found what broke it. This is where Haney made it click, I guess. Oops! – Kendra Oct 6 '14 at 22:01
  • 1
    Quite surprised to see that the lightbox is the actual submit button and the submit button is triggering the lightbox click (and not the other way around). @Kendra now I feel guilty somehow. – Spokey Oct 7 '14 at 7:56
  • @Spokey If anyone's guilty, it's whoever broke it, not the one requesting a fix. :) I certainly don't blame you, that's just the change that mentions the issue mentioned in this answer. I could be completely wrong. – Kendra Oct 7 '14 at 17:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .