14

It appears that the button to execute a runnable snippet is not visible anymore?

It still is visible when creating a new question/answer or while editing a question/answer

console.log('StackOverflow');


This happens for me on:

  • Firefox 131.0 (64-bit)
  • Chrome 129.0.6668.90 (64-bit)
18
  • Neat, that's fun. It's just not rendering it at all. I do see it on some of my existing answers on SO, so this may be related to the content of your snippet somehow.
    – Kevin B
    Commented Oct 3 at 5:57
  • 3
    Stack Snippets are now always safe
    – VLAZ
    Commented Oct 3 at 5:59
  • Thanks for the heads-up - Bit confused why the button is still there when posting/editing
    – DarkBee
    Commented Oct 3 at 6:02
  • 2
    @DarkBee why are you closing this as a duplicate of that? VLAZ was joking if you didn't get that... Commented Oct 3 at 6:04
  • Yeah...it was a joke.
    – VLAZ
    Commented Oct 3 at 6:04
  • Seems I haven't had enough coffee yet then.. I actually thought the button was temporarily disabled - Voted to re-open..
    – DarkBee
    Commented Oct 3 at 6:06
  • 4
    Looking at the HTML the API returns it is missing the divs and classes that are normally present for a snippet. Looking at the response for the FAQ answer that HTML is present in the server response there, so this issue only seems to be present for new posts. Commented Oct 3 at 6:22
  • Can confirm the button is still there for older snippets
    – DarkBee
    Commented Oct 3 at 6:23
  • 2
    @AbdulAzizBarkat old posts have the rendered HTML cached. Presumably, if you edit an old post with a snippet, it will also render it just as a code block. EDIT: confirmed - I killed the snippet after editing the post. Although I had to specifically edit the snippet, I first added a new line outside but the snippet remained.
    – VLAZ
    Commented Oct 3 at 6:23
  • 2
    Somehow my recent answer had the following code added: <!-- begin snippet: js hide: false console: false babel: false babelPresetReact: false babelPresetTS: false --> whereas it should have been <!-- begin snippet: js hide: false console: true babel: false --> --- so I changed it and now my answer now has the code snippet button rendering.
    – PeterJames
    Commented Oct 3 at 6:25
  • @PeterJames ah, so they've decided to update the babel thing... Update the version of Babel Standalone (and others) used by Stack Snippets
    – VLAZ
    Commented Oct 3 at 6:26
  • 1
    @PeterJames you might want to post that as an answer stating it as a workaround until the company fixes it. Commented Oct 3 at 6:28
  • @VLAZ I posted an answer yesterday and it had the old begin snippet code and worked without a problem, so if they have changed anything it would appear to be very recent.
    – PeterJames
    Commented Oct 3 at 6:29
  • @DarkBee - The button is there, but the snippets are broken if they have React - meta.stackoverflow.com/questions/431790/… Commented Oct 3 at 12:03
  • 1
    @VLAZ - My comment wasn't clear, sorry, but the bug report it links to is. I'm talking about existing posts with React snippets, not new ones. Commented Oct 3 at 12:09

3 Answers 3

7

Just to update on what was behind this: we rolled out the snippets backend with Babel updated to 7.25.6, which requires various data-presets for things to work. (In this particular case we're interested in the react preset.)

The corresponding frontend deployment lagged behind slightly (many thanks, integration tests), plus a hotfix was required for backward compatibility for pre-existing React snippets. It looks like any snippets created during that time have ended up misconfigured, which I think is to do with the HTML post-processing step (so is baked into the posts).

It may be a case, at this point, of just rooting those out and removing the babelPresetReact flag, as I've rudely done with the snippet in this question. I'll have a look at whether this can be done programmatically to save everyone some time.

6

Here's a workaround for pure js snippets.

Somehow my most recent answer had the following code added:

<!-- begin snippet: js hide: false console: false babel: false babelPresetReact: false babelPresetTS: false -->

so I looked at an answer I posted a day earlier and it had:

<!-- begin snippet: js hide: false console: true babel: false -->

so I changed this and now my most recent answer has the code snippet button rendering properly.

Please note that you will probably have to edit the code snippet manually in the editor after clicking "Save & insert into post" from the Code Snippet editor.

1
  • 1
    This works for pure js snippets but eg reacts snippets won't work without babel support.
    – 0stone0
    Commented Oct 3 at 9:47
1

Just wana add that When I start to create new question (not post it) the following code is generated by snippet editor (whih contains babelPresetReact: false babelPresetTS: false (as PeterJames mention) attributes witch prevent "Run snippet" button to appear in question/answer normal (view) mode (also there is problem with "hide" flag)

So te problem is on snippet editor level (not during post)

babel

2
  • 4
    Isn't that what the other answer already says?
    – VLAZ
    Commented Oct 3 at 10:31
  • @VLAZ - yep (I edit answer) - just wan't to add that snippet-editor cause problem Commented Oct 3 at 10:33

You must log in to answer this question.

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