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.
479
questions
4
votes
0
answers
152
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 ...
3
votes
0
answers
63
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)
4
votes
0
answers
75
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 ...
3
votes
0
answers
81
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 ...
12
votes
2
answers
246
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?
6
votes
0
answers
96
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 ...
2
votes
0
answers
154
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 ...
22
votes
0
answers
380
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 ...
19
votes
1
answer
355
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 ...
25
votes
2
answers
578
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',
...
2
votes
0
answers
44
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 ...
1
vote
0
answers
135
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, ...
4
votes
2
answers
265
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 ...
15
votes
1
answer
289
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 ...
3
votes
2
answers
79
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 ...
-3
votes
1
answer
98
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 ...
3
votes
0
answers
50
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 ...
1
vote
0
answers
75
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 ...
2
votes
0
answers
88
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 ...
5
votes
0
answers
122
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 ...
6
votes
1
answer
129
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 &...
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.
12
votes
1
answer
197
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 ...
27
votes
2
answers
496
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 ...
5
votes
2
answers
271
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 ...
8
votes
0
answers
67
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 ...
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 ...
4
votes
0
answers
338
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 ...
3
votes
1
answer
76
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 ...
6
votes
1
answer
125
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 ...
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: ...
13
votes
3
answers
728
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 ...
3
votes
0
answers
75
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 ...
3
votes
1
answer
64
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 ...
5
votes
0
answers
49
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 ...
6
votes
0
answers
63
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 ...
-9
votes
1
answer
142
views
Displaying HTML first on Stack Overflow snippets [closed]
Currently, code snippets are displayed JavaScript first, then CSS and finally HTML. Regardless of the order they appear in the post source or anything.
This does not make any sense to me. Does it for ...
-13
votes
0
answers
122
views
Can we have Runnable Python Snippet? [duplicate]
Since Python language is getting more popular, can we have Runnable Python Snippet implemented in SO?
Why Python?
It was ranked second to JavaScript/HTML/CSS in most popular technologies in 2021.
It ...
-26
votes
1
answer
209
views
WebAssembly should be usable in code snippets
I don't see any way to use WebAssembly in snippets; just HTML, JavaScript and CSS. Allowing WebAssembly would let any compilable language be indirectly used for snippets. It's not complicated to let ...
-19
votes
1
answer
159
views
Tests for stack snippets
When we ask users to add their code as a minimal reproducible example via Stack Snippets and tell us what they expect the code to do, the snippet is quite helpful but we have no way to verify if an ...
3
votes
0
answers
50
views
Code snippets feel inconsistent
Could we combine "Expand snippet" and "Full page" into a single and consistent experience?
If not then at least improve the general wonkiness?
Expand snippet
I can run code in ...
3
votes
1
answer
144
views
Code snippet console scrolling issue in Chrome
I recently provided this answer and was trying to see if my output string is valid but the console window seems to cut off after a certain point.
Could we make this re-sizable, expandable, or scroll-...
2
votes
0
answers
125
views
Is this Moment.js plugin broken, or are Stack Snippets not working?
I was updating my self-answer to Filter out non-contiguous date using momentjs and twix.js and tried to make use of Stack Snippets, but it's not working.
I'm trying to understand if the Moment.js ...
6
votes
1
answer
265
views
The “Close” button for the snippet “Full page” doesn’t work when site isolation is enabled
If you create a snippet in a question or an answer and click on “Full page” then the “Close” button is not clickable. Am I the only one to whom this happens? This was tested in Firefox, Safari and ...
2
votes
2
answers
122
views
How do I correctly include the latest Babel and React libraries in a code snippet? [duplicate]
I would like to include both the latest Babel (for async/await syntax support) and the latest ReactJS (for hooks) in my code snippet, but I get the following error:
"message": "...
-1
votes
2
answers
248
views
How do I add CSS libraries to my Stack Snippet? [duplicate]
When I asked the question I wanted to include a Stack Snippet, but the images, fonts and the Bootstrap grid were giving me issues, so I'm asking if there is a way that could be fixed.
This is what I'm ...
2
votes
2
answers
268
views
Is it possible to embed DartPad into a Stack Overflow post?
I'm wondering if there is a way to embed DartPad in the Stack Overflow question and answer like mentioned here in the Embedding Guide.
I tried to embed but failed, this would be helpful to test code ...
-8
votes
2
answers
299
views
Can we disable Stack Snippets for New Users?
Runnable code snippets (a.k.a. "Stack Snippets") are a great feature. However, they are also being misused (increasingly frequently, in my experience) by new users, who are using the "...
5
votes
0
answers
102
views
Why does the Stack snippets console error not show the correct line number?
When there is an error in a Stack snippet JavaScript code, an error message is displayed, but the "lineno" in the message is incorrect.
In the following snippet, it Shows the error is on ...