Skip to main content

Questions tagged [stack-snippets]

Stack Snippets are runnable code sandboxes of the front-end languages HTML, CSS, and JS for use within a Stack Exchange post. Use this tag for bug reports, feature requests, and discussions explicitly relevant to these snippets and their underlying technologies.

Filter by
Sorted by
Tagged with
-9 votes
1 answer
140 views

Remove "Tidy" feature from Stack Snippets [duplicate]

The Stack Snippets editor includes a "Tidy" button. This button uses a outdated version of js-beautify which does not include support for syntax changes in ECMAScript 2020 and newer. Running ...
Jeremy Banks's user avatar
1 vote
0 answers
46 views

Warn about unsaved changes in code snippet

Context: While writing a question or answer, an attempt to leave the page (by trying to close that browser tab or clicking on a link) triggers a confirmation dialog. Moreover, returning to the same ...
root's user avatar
  • 2,334
15 votes
1 answer
122 views

Existing React Stack Snippets broken by update

The recent update to Stack Snippets breaks existing React snippets in posts. The Run code snippet button is there, but the snippet doesn't work anymore. (Related but different: Button to "Run ...
T.J. Crowder's user avatar
1 vote
0 answers
49 views

Problem with snippet in an answer I edited [duplicate]

I edited this answer (I made changes and added the snippet at the bottom) Here is code of my revision. After that, when I edit this answer I see a snippet that I can run: But when I not in edit mode (...
Kamil Kiełczewski's user avatar
14 votes
3 answers
230 views

Button to "Run code snippet" not appearing when question/answer is posted

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('...
DarkBee's user avatar
  • 15.8k
3 votes
1 answer
183 views

Are Stack Snippets always safe to run?

Whenever I see a code snippet, I feel like it is not always safe to run something I don't know in a website. It might contain malicious code or execute something I don't want. So, I would like to know ...
holydragon's user avatar
  • 6,708
3 votes
0 answers
96 views

What happened to the Stack Snippet button? [duplicate]

This is what my tool bar looks like when asking a question. According to this answer, there is supposed to be a stack snippet right next to the images button. That answer has examples of Stack ...
blazgocompany's user avatar
9 votes
1 answer
188 views

Stack snippets no longer show logs

The stack snippets have lost their logging ability as of very recently. Demo. And note that the console in the stack snippet is enabled. console.log("hello"); Happens in both Firefox and ...
VLAZ's user avatar
  • 28.8k
20 votes
1 answer
166 views

Staging Ground editor doesn't have Stack Snippets

The Stack Snippet icon in the Staging Ground editor inserts a code block instead. The Markdown preview mode doesn't render Stack Snippets, either.
wizzwizz4's user avatar
  • 6,416
1 vote
1 answer
77 views

Wrong ordering of Stack Snippets console output

I noticed what seems to be a pretty bizarre bug with the in-built Stack Snippets console in my answer here: https://stackoverflow.com/questions/77858025/how-to-negate-the-whole-regex/ When I run the ...
Lionel Rowe's user avatar
  • 5,871
-24 votes
1 answer
196 views

Is it possible to auto-convert HTML/CSS/JS code into a Stack Snippet?

Why can't there be a automatic feature that detects if its HTML/CSS/JS code and auto makes it into a Stack Snippet? This would be very helpful and nice because I always find so many posts WITHOUT a ...
Truder's user avatar
  • 60
2 votes
0 answers
126 views

How can I define the order for a code snippet? [duplicate]

I'm trying to ask a CSS-related question with some demo code. I have some JavaScript there which is not directly related to the problem and is only used to toggle some dynamic state so that the ...
timetowonder's user avatar
  • 5,401
3 votes
1 answer
204 views

"</script>" causing issues in code snippet editor

console.log('</script>'); This would end up with this HTML: <script type="text/javascript"> console.log(' </script> '); That means the string "</script>&...
Hao Wu's user avatar
  • 20.5k
5 votes
0 answers
158 views

Support newer versions of Vue.js 3 in Stack Snippets [duplicate]

Why don't we still have any of the Vue.js 3 versions close to end of 2023, available to choose when due to GitHub, Vue.js 3 has been with us since the end of 2019 (of course, we still can add it as an ...
Damian Chudobiński's user avatar
4 votes
0 answers
64 views

Will the stack-snippets formatter support modern JavaScript syntax? [duplicate]

Clicking "Tidy" breaks JavaScript code if it contains ?. Before formatting: const a = { b: 3 } console.log(a?.b) After formatting: const a = { b: 3 } console.log(a ? .b)
Konrad's user avatar
  • 24.6k
4 votes
0 answers
77 views

Stack Snippets console doesn't display JS BigInts [duplicate]

1n is a BigInt literal in JavaScript. BigInts currently display incorrectly/ don't display at all in the Stack Snippet console; console.log(1n) logs nothing and console.log([1n]) logs [null] instead ...
Lionel Rowe's user avatar
  • 5,871
3 votes
0 answers
119 views

Add "Edit snippet" to snippets in an answer

Sometimes there're several snippets in an answer. It's very confusing/difficult to edit them in that case. Usually you look at a snippet you want to edit. Then you click 'Edit' for the answer it ...
Alexander Nenashev's user avatar
20 votes
2 answers
357 views

How do I make a code snippet with the new editor? Where did the button go?

Here is a comparison of old: and new: Where did the code snippet go? How can I make it now?
danik0011's user avatar
  • 123
6 votes
0 answers
101 views

Stack Snippet fullscreen close button is invisible [duplicate]

I'm running a Stack Snippet fullscreen, however the "Close" link is almost invisible. See image: Zoomed in: Could the close link have a solid background? Something like this: Or even ...
Ben the Coder's user avatar
2 votes
0 answers
175 views

Latest Chrome breaks Stack Snippets (113.0.5672.126)

I've just upgraded my Google Chrome to version 113.0.5672.126 (Official Build) (arm64) on macOS 13.2.1. But afterwards, all Stack Snippets stopped working I've uninstalled all my extensions I've ...
0stone0's user avatar
  • 43.1k
25 votes
1 answer
593 views

Please update the library versions included as "Options" in Stack Snippets (code provided)

Updating the list of libraries was last done in response to a 7-year-old request. That one was status-completed after Shog9 updated all of the listed libraries to the most recent versions available on ...
mplungjan's user avatar
  • 177k
20 votes
1 answer
373 views

Improvement request for Stack Snippets when misclicking preview area

While I was answering a question from Stack Overflow, I put some code in the Stack Snippets area. Sometimes, when I want to change back the code that I have typed, I wrongly click on the sentence edit ...
Jordy's user avatar
  • 1,950
25 votes
2 answers
584 views

How to deal with a user reformatting snippet data to be in a single line

A user is going around reformatting Stack snippets to put all provided data on a single line, effectively turning things like this: const data = [{ id: 'id1', entries: [{ key: 'key1', ...
Robby Cornelissen's user avatar
2 votes
0 answers
47 views

Broken snippet rendering [duplicate]

This question (in revision 1) has a really weird StackSnippet content that doesn't want to display properly. In the question it renders nested scrollbars: Scrolling down to the bottom of the outer ...
Bergi's user avatar
  • 662k
1 vote
0 answers
139 views

Why does Stack Overflow's code snippet show a different result compared with a normal editor?

Today, when I was answering a question, I observed that the result from the code snippet Stack Overflow give us is different from other editors. For example, this and this both shows the right result, ...
Han Han's user avatar
  • 416
8 votes
2 answers
777 views

How can I include Tailwind CSS as external source in a Stack Snippet?

The recommended way of directly including Tailwind CSS according to their documentation is to add <script src="https://cdn.tailwindcss.com"></script> to the HTML head. But when ...
andreas's user avatar
  • 16.9k
15 votes
1 answer
323 views

Feature request to allow executable XSLT code snippets

For questions related to HTML/JavaScript/CSS, Stack Overflow allows you to embed executable code snippets in a question and/or answer. I would suggest to allow that too for XSLT questions: XSLT 1.0 is ...
Martin Honnen's user avatar
3 votes
2 answers
99 views

How do I hide the HTML preview for a Stack Snippet?

I have a simple JavaScript code snippet that displays an alert message. alert("Hello world!") Running the code snippet shows the alert as expected, but it also displays a white empty box ...
Stevoisiak's user avatar
  • 26.5k
-3 votes
1 answer
99 views

SO Snippet should warn about wrong HTML usage

Considering this question about a not-working CSS :first-child selector. The OP posted a question with a full HTML structure in the question, and later it was edited into an SO Snippet showing that ...
Justinas's user avatar
  • 43.4k
3 votes
0 answers
55 views

Add toggle line wrap in snippet editor

I pasted a really long line of code into the snippet editor—so long that the editor decided to ignore the rest of it. Here you can see that it has overflowed to the next line (for some reason, there's ...
k.tten's user avatar
  • 26.2k
1 vote
0 answers
83 views

When you click on "Tidy", "/>" from "<img/>" goes to the next line if there are too many characters

It's just a little thing, but I noticed that if an img element is closed like <img /> and you click on the Tidy button, the /> is put on the next line when there are too much characters ...
Cédric's user avatar
  • 2,619
2 votes
0 answers
92 views

Add more languages to Stack Snippets [duplicate]

Stack snippets are a great feature. They greatly increase the reproducibility of answers in JavaScript, HTML, and CSS, as well as supported frameworks like React. Already, many answers link to ...
mousetail 'he-him''s user avatar
5 votes
0 answers
135 views

Show a warning when on Stack Snippets throwing errors

Tl;Dr: Make use of the Ask question warnings to reduce the misuse of Stack Snippets. Automatically run it in the background when the user click the "Review your questions button", if there ...
Wicket's user avatar
  • 37.9k
6 votes
1 answer
276 views

In Stack Snippets, "console.log(map)" prints "{}" instead of the contents of the Map

When answering this question, I tried to put my JS-only code into a snippet. Here's the snippet: const lines = ['The foo is black', 'The bar barks']; let wordCount = new Map(); for (let i = 0; i &...
Michael M.'s user avatar
0 votes
0 answers
69 views

Why am I seeing two snippet buttons? [duplicate]

I just noticed there are two snippet buttons!? Clicking either of them works as expected. Pressing the shortcut Ctrl + M opens both modal dialogs at the same time.
holydragon's user avatar
  • 6,708
12 votes
1 answer
201 views

I see two snippet buttons in the editor

I'm using Firefox 104.0.1 (64-bit). I see this in Private tabs, too. I also see it in Chrome. It only shows up on the "Ask Question" page (both in the question editor, and also in the answer ...
Daniel Kaplan's user avatar
27 votes
2 answers
503 views

Should I suggest edits to transform code blocks into Stack Snippets for HTML/CSS/JS questions?

I occasionally come across questions which contain HTML/CSS/JS which are formatted using the standard code blocks (backticks or indentation) that would be better as a runnable snippet. Is it good ...
Daniel Black's user avatar
6 votes
2 answers
470 views

TypeScript in Stack Snippets

Lately, I have seen various questions that use TypeScript in Stack Snippets. They look like this: There is a problem with my code. Instead of doing x, it does y. Here is my code: function ...
Caleb Liu's user avatar
  • 747
11 votes
0 answers
100 views

Tidy button on Stack Overflow code snippet tool breaks optional chaining in JavaScript code [duplicate]

Bug report: Create a code snippet and try and use optional chaining. Click Tidy and see it add erroneous spaces to the code around the ? in the optional chaining portion. //optional chainging ...
WillD's user avatar
  • 6,372
1 vote
0 answers
58 views

Strange behavior in Stack Overflow: unwanted scrolling of the page on Run code snippet button click [duplicate]

When I edit a new question or answer, if I insert a code snippet and then I click on Run code snippet blue button, to check if it works as expected, I noticed that such an action triggers a wrong ...
willy wonka's user avatar
  • 1,656
4 votes
0 answers
340 views

How can I include HTML and JavaScript code on Stack Overflow? [duplicate]

I want to post my first question here, and I would like to insert HTML and JavaScript code. I've been checking questions to different answers, and there is a "run code" button that runs both ...
Rher's user avatar
  • 51
3 votes
1 answer
89 views

Snippet formatting issue when editing/submitting an answer [duplicate]

This snippet is a valid "Question" but it's an invalid "Answer" on Stack Overflow. Keep getting this error when I try to submit this code snippet as an answer: Your post appears ...
Aldo's user avatar
  • 921
6 votes
1 answer
135 views

Is it possible for a Stack Snippet to get information about the post it's running in?

Stack Snippets have many uses, and while I don't use them that often on Stack Overflow (I haven't been active for while, let alone in the javascript tag), they also have their uses on other sites in ...
Glorfindel's user avatar
  • 22.6k
2 votes
0 answers
101 views

Sass in stack snippets [duplicate]

Most of you have probably seen stack snippets, like the one below. function clickMe() { alert("Button clicked!"); } button { background-color: rgb(29 78 216); border: none; border-radius: ...
Caleb Liu's user avatar
  • 747
15 votes
3 answers
2k views

How do I create a Vue.js Stack Snippet?

I found detailed instructions here on how to create a Stack Snippet for React, but I have been unable to figure out how to do so for a Vue.js component. How do I create a runnable Stack Snippet of a ...
20 votes
1 answer
2k views

Is this 'Run code snippet' with payload an attempt to infect SO users' machines with a virus?

Just wondering if there's a risk to a user's machine by clicking "Run Snippet" in questions like this one I'm suspicious because on the face of it the question doesn't look like it needs to ...
Caius Jard's user avatar
  • 74.4k
3 votes
0 answers
78 views

Close button when trying snippets on full screen might not be noticable

On my recent question, since I was trying the stack overflow snippet in full screen for the first time I couldn't notice that there was a close button on the top right corner, and that would be the ...
Affes Salem's user avatar
  • 1,641
3 votes
1 answer
65 views

Running Snippet in full screen as reviewer then clicking back arrow redirects me to another question

I recently got my 500 rep points and had access to the reviewing actions, but one of the questions I was reviewing had a PHP related snippet. I tried to test that snippet on full screen which doesn't ...
Affes Salem's user avatar
  • 1,641
5 votes
0 answers
73 views

Full screen snippets has an incorrect z-index in post revisions

Example post with a snippet https://stackoverflow.com/posts/71191950/revisions Click "Run code snippet" and then click the "Full page" link The top bar, side bar, and post ...
Samuel Liew's user avatar
  • 78.9k
6 votes
0 answers
68 views

Moderator Redaction flags does not display collapsed code snippets

The moderator redaction tool does not display the redacted diff if the redacted bit was in a collapsed code snippet, so we cannot see what was redacted for approval. There aren't any buttons to expand ...
Samuel Liew's user avatar
  • 78.9k

1
2 3 4 5
10