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.
473
questions
3
votes
0
answers
60
views
Save snippet button sometimes throws an error [duplicate]
The Save & insert into post button in Stack Snippets sometimes throws an error and the popup doesn't close.
Uncaught TypeError: Cannot read property 'save' of undefined
When I refresh the ...
5
votes
0
answers
135
views
Snippet with react-router-dom routing
I'm trying to run this snippet here on Stack Overflow.
I'm using react-router-dom from a CDN. I'm able to match the first route, but somehow I can't change to a different route.
Is it possible to ...
20
votes
2
answers
489
views
How do I demonstrate a preventDefault problem on a link in a Stack Snippet?
I need to demonstrate a problem with using preventDefault to prevent following a link, but Stack Snippets won't let me have a link that navigates to another page or opens a new window. So how do I ...
19
votes
0
answers
228
views
Please make the font and color settings in the snippet editor match the result in the question's code block
I only noticed today that there is mismatch between the display in the StackSnippet editor:
and the resulting HTML in the code block in the question:
First of all, the color coding is different, and ...
20
votes
1
answer
354
views
Should Guided Mode allow snippets?
Currently new users are led to guided mode to ask their question. Guided mode does not have an option to add a Stack Snippet. I have a feeling, at least for JavaScript/HTML/CSS questions, this leads ...
68
votes
0
answers
1k
views
Update the version of Babel Standalone (and others) used by Stack Snippets
Please update the version of Babel Standalone used by Stack Snippets (and update the available versions of other scripts in the drop-down lists; ideally, update that list automatically). It's ...
13
votes
0
answers
276
views
Do we really need to validate "file" extensions for externals in the code snippet editor?
As we all know, "file"-suffixes are effectively meaningless w.r.t. HTTP URLs. The type of the resource is determined by the Content-Type header, not its path-suffix.
So, I tried to add the following ...
9
votes
0
answers
314
views
Is there a magic link for [snippet]? [duplicate]
Is there a page I can direct users to, giving information on how to create code snippets?
I've found this one, but it's a bit old and doesn't reflect the current layout/options.
Is there a magic ...
23
votes
1
answer
603
views
Why won't this snippet with async await work here on Stack Overflow snippet editor?
Why won't the following snippet work here on Stack Overflow?
I'm trying to add some example of basic async/await and returned promises.
This exact same piece of code works just fine on my development ...
29
votes
2
answers
698
views
Stack Snippets that assign `var location` at the top scope redirect and produce “Server Error in '/' Application.”
Look at the snippet below. It's a perfectly normal snippet (look at the markdown if you don't believe me). It's not working.
var location = {
map: {
geo: "20.471884,-157.5056",
p: "...
13
votes
1
answer
451
views
Why doesn't the code snippet's console display string-key properties of an array?
I decided to post this issue following this one (which is not a real Javascript issue in the end).
After a bit of searching, I found out that string-key/value pairs of an array are not showed in the ...
13
votes
0
answers
188
views
Saving a Stack Snippet resets scroll to the top of the page
I've noticed while adding Stack Snippets or editing existing ones to answers, the scroll position is being reset to the top of the page when you click "Save and Insert into Post" to save your Stack ...
55
votes
2
answers
984
views
Reassigning window.name inside a Stack Snippet results in unexpected popup
Run the following snippet twice (either in the post proper, or in the snippet editor). On subsequent runs, rather than the form posting to the embedded result iframe, a new window is opened:
...
11
votes
1
answer
463
views
Is it possible to load scripts from GitHub into the code snippet editor?
I tried to show an example in this post, which was loading my custom scripts from GitHub, but the script failed with "Uncaught TypeError: $(...).selectmenu is not a function".
But if I copy the ...
6
votes
1
answer
97
views
"copy snippet to answer" is not working any more
I am not able to copy the code of the question and I get this error (tested with different questions and cleared cache):
This is a test snippet to see if the issue occur on meta or not.
* {
...
2
votes
0
answers
36
views
Babel causes document.write to break CSS in Stack Snippets
I know that document.write is bad,¹ but this is terribly inconsistent and doesn't make much sense.
document.write("babel: false");
*:after {
content: "it works";
}
document.write("...
21
votes
2
answers
779
views
How can I add code to the head element when posting a code snippet?
I wanted to post a code snippet with a meta tag in the document head, so I created a code snippet with a complete HTML document.
Later I saw that Stack Overflow automatically creates an HTML document ...
22
votes
2
answers
1k
views
All my code is properly formatted, yet I am unable to post an answer due to unformatted code. Why?
I was answering this question, and I was unable to post my answer due to containing code that is not properly formatted as code. All my code has been formatted properly as far as I can tell.
Here is ...
5
votes
0
answers
82
views
How can I search for posts that contain Stack Snippets? [duplicate]
I want to search for posts which have live Stack Snippets.
Example post: the snippet markdown content is:
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: ...
9
votes
1
answer
115
views
Hide main page content while in the Stack Snippet editor so that browser Find (Control-F) behavior is intuitive
In most browsers, one can press Control-F or something similar to search the current page for a phrase. Pressing Enter will usually scroll you to the next match for the found string. This is extremely ...
22
votes
0
answers
325
views
Hidden Stack Snippets are not accessible and violate web standards
I noticed recently in a question about accessibility, that a snippet I included (marked as hidden by default; as it includes more details then strictly necessary for the question) is not very ...
43
votes
1
answer
511
views
Is Stack Snippet that useful when it cannot help discovering errors when writing an answer?
I just provided an answer with my first Stack Snippet. I choose to construct the answer in the snippet editor and debug it right within. My expectation was to use this great tool as a debugger which ...
17
votes
1
answer
668
views
Indentation of tabs and spaces is inconsistent in Stack Snippets
When I write code using JS/HTML snippet editor (orange icon):
and paste code which contains one or more tab () characters as line indentation, then the snippet editor shows me this:
The same code in ...
19
votes
0
answers
324
views
SO-hosted example images for stack snippets [duplicate]
Can we have some support for example images to be built into stack snippets?
Images play an important role in many examples, but afaik the only way to use one is to get a link to the SO logo, or to ...
7
votes
1
answer
118
views
Snippet editor format issue when pasting larger quantity of code [duplicate]
This is not the first time this has happened.
I recently came across a question with this piece of code (not in a snippet):
function Decode() {
var temp = "",
i, c = 0,
out = "";
...
-3
votes
1
answer
126
views
"Copy snippet to answer" not working
I saw an answer while browsing in Stack Overflow without login. There was a "code snippet" in the answer. I wanted to try the "code snippet" in this answer. But "Copy snippet to answer" option is not ...
3
votes
0
answers
35
views
Stack Snippets syntax completely borks when indented by four spaces [duplicate]
Here's a Stack Snippet:
for(var o of document.getElementsByTagName("input")){(o=>o.addEventListener("change",e=>console.log(o.value=o.value?o.value[0]:"")))(o)};
input{width:1em;}
<...
-1
votes
1
answer
126
views
Can not make sure that code snippet result is updated
When I write code in a code snippet I use the "RUN" button many times to check the current state of my code, but there is no indication to make sure if the result is changed so I click the Run button ...
8
votes
0
answers
267
views
I cannot edit snippet when improving edits
As said in the title, when I find a pending edit and I try to improve it I cannot edit the snippet inside:
I don't know if it was always the case but I am pretty sure I was able to do this before....
17
votes
1
answer
499
views
How to use the regular code snippets in the 2018 Stack Overflow update
I am a little confused with the new update of Stack Overflow, particularly on using the regular JavaScript/CSS/HTML code snippets we used to have to write our questions. Now the new update made it ...
4
votes
3
answers
721
views
Use of CodeSandbox vs built-in code snippets
Getting really annoying to see a lot more questions using codesandbox like this one: Material UI transition out and in on single button click
Why aren't they using the built-in code snippets? There's ...
34
votes
0
answers
606
views
Can Stack Snippets be added to SO for Teams? [closed]
SO for Teams is targeted at teams of developers. While that's probably not a classification that applies to all its customers, I'd expect the majority of them to be technical teams.
Taking that as ...
5
votes
0
answers
263
views
Missing referer header in Chrome when using code snippet
I created an answer for HERE maps autocomplete API on Stack Overflow and I'm having an issue with the HTTP_REFERER header not being sent when using Chrome browser (works fine w/ Edge and IE).
This ...
2
votes
1
answer
55
views
Console broken in old snippets
This is regarding an answer I posted long long ago, so long ago: Answer: Split string into sentences.
When we try adding a snippet, by default, the comment looks like this:
<!-- begin snippet: js ...
6
votes
0
answers
84
views
Snippet HTTP Error 503: service unavailable [closed]
Basically the same as this one : Stack Snippets Returning a 503 Service Unavailable Error
Quite annoying. Tried with both firefox and chrome.
(Sorry if it's a duplicate)
A question with snippets ...
440
votes
1
answer
3k
views
Add VueJS to preset snippet options
Request
As the title says, I would like vue added to the preset libraries already present under the options portion:
The following are links that can be used for this:
https://cdn.jsdelivr.net/npm/...
76
votes
0
answers
717
views
Add an option to hide or collapse less relevant snippet sections
Snippets are very useful, but often fill up a lot of the answer with irrelevant code.
(E.g. in JavaScript questions, often the solution can be demonstrated by changing a tiny part of the JavaScript ...
50
votes
1
answer
896
views
Stack Snippets Console can't output ES6 data types
console.log(new Map([["a", 1], ["b", 2]]));
// console: Map(2) {"a" => 1, "b" => 2}
// SO console: {}
console.log(new Set([1, 2, 3]));
// console: Set(3) {1, 2, 3}
// SO console: {}
...
11
votes
1
answer
410
views
Using Code Snippet's JavaScript Tidy option to indent code of other languages
I've been using the JavaScript Tidy option in the Code Snippet popup to edit and indent code in Java posts. I far as I know it works perfectly fine with Java.
Is it OK to do so?
What other languages ...
3
votes
1
answer
137
views
On every snippet with Privacy Badger: Uncaught SecurityError: Failed to read the 'localStorage' property from 'Window'
It's been bothering me for some time. Every snippet I try to run will output an error:
Uncaught SecurityError: Failed to read the 'localStorage' property from 'Window': The document is sandboxed and ...
44
votes
2
answers
667
views
How can we keep people from using 'JavaScript/ HTML/ CSS snippet' option with other languages?
I have mostly seen that users use the JavaScript snippet option with other languages like Python, C++, and C. How can we do our best to help them understand this option?
Here is a post in which a user ...
1
vote
1
answer
57
views
Using Stack Snippets outside of Question
As mentioned here, I'd find it useful to have the ability to use stack snippets outside of the question and answer format. The idea would be to implement something very similar to a JSFiddle which we ...
11
votes
1
answer
341
views
Why does the editor suffer when using a lot of stack snippets?
When writing detailed answers, I need to use many stack snippets to show different states in order to explain some complex behavior, but this makes the editor terribly slow and annoying. I see my self ...
9
votes
1
answer
313
views
Occasional failure to save when improving a question using the Snippet Editor
Occasionally (say, 1 in every 25) when improving another users' question by adding their existing code to a snippet using the editor I am unable to save the changes I have made; nothing happens when I ...
0
votes
0
answers
31
views
When to edit code/links into snippet? [duplicate]
Being that I'm relatively new in my education on front-end development, I've come across a lot of older, basic questions that I use to help myself along. Oftentimes, if there is plain code there, I ...
4
votes
1
answer
87
views
Snippet no more working for downvoted posts [duplicate]
I discovered something strange but probably intentional. When a post that includes a working snippet gets 3 downvotes, the button to run the snippet or to copy it disappears!
Here is a screenshot of ...
7
votes
1
answer
129
views
Error in Stack Snippets console has incorrect lineno and colno
When there is an error in the JavaScript code in a Stack Snippet:
asoidf
I find the error message quite unhelpful.
Error: {
"message": "ReferenceError: asoidf is not defined",
"...
5
votes
0
answers
345
views
Stack Overflow snippet "begin snippet" purpose
Stack snippets have three parameters:
begin snippet
hide
babel
hide hides the snippet so it doesn't take up too much space, babel probably does something complicated that I don't understand, but ...
36
votes
1
answer
457
views
SO CSS animations overriding snippet CSS animations
Take the code below, which should flash the <div> from red to blue:
@keyframes flash {
from { background-color: red; }
to {background-color: blue; }
}
div {
padding: 20px;...
14
votes
2
answers
629
views
How to provide additional code to comment an answer?
I asked a question and provided corresponding code inside my question using the tools Stack Overflow provides. Now, someone answered, but I feel like I need to provide additional code specific to his ...