-8

Stack Overflow offers a great snippet tool to add HTML/JS/CSS to questions and answers, but sometimes we just want to try different test-cases to someone else's snippets or run whatever quick tests we desire.

Today, the way we can achieve that is by clicking the button "Copy snippet to answer" and there we can tweak and test the code. But that's not ideal because:

  1. It automatically creates a draft of an answer that will never become an actual answer;
  2. Doesn't work if the user already answered that question or if the question isn't accepting answers.

The snippet editor is a powerful lightweight tool that runs in the client-side only, so I think it would be awesome to have quick unrestricted access to this tool to run quick tests in other people's codes.

My proposal is

...replacing the button "Copy snippet to answer" with the button "Edit snippet" (or another wording). This new button will open the snippet editor with the current code, allowing the user to freely tweak with it.

In this case, the button "Save & insert into post", will instead have the words "Save & add to answer" for clarification.

This also saves a step to people who actually wants to add an answer using other people's snippets, because currently they have to click "Copy snippet to answer" and then "edit the above snippet" for the same result.

10
  • 7
    You can just delete the answer draft.
    – TylerH
    Commented Aug 5, 2020 at 13:23
  • 4
    Alternatively, you can just click "edit post -> edit snippet" and then tweak around as you like, but then don't click save. Or copy the HTML and CSS to a proper sandbox like JSFiddle or CodePen.
    – TylerH
    Commented Aug 5, 2020 at 13:24
  • 2
    Finally, if "save & insert into post" is changed to "save and add to [a new] answer", then you've effectively eliminated the possibility for someone to add a code snippet to a question, or to update their own code snippet within an existing answer.
    – TylerH
    Commented Aug 5, 2020 at 13:25
  • There is a lot of HTML/JS/CSS sandbox out there. On line, in EDI, offline with a browser , a text file , and a jquery. With node some of the well know online tool offer offline mode. Commented Aug 5, 2020 at 13:29
  • @TylerH I disagree with your last comment because the changing of wording would be just for this case and you can't add an existing snippet to a question already. Besides that, my proposal is for optimization of a process that I recognized that can already be done. I propose a change of the UI of StackOverflow for better usability without any penalties to the site on its own. We are talking of a tool that runs client-side only. Why not make it more accessible?
    – Pedro Lima
    Commented Aug 5, 2020 at 13:32
  • 1
    @PedroLima For starters, you're wrong; you can have multiple snippets in a question. More importantly, I think you are missing the point. Say I am writing a question, and I want to add a code snippet to it. I click the code snippet button, add my code, and then go to save it/insert it into the post... only now I don't see that button! I only see "Run" and "Save and Insert into Answer" (your suggestion). Oops! Guess only answers can contain snippets now.
    – TylerH
    Commented Aug 5, 2020 at 13:44
  • 1
    @TylerH I believe the OP is thinking that "Save and Insert into Answer" button would show for people other than the poster of the question. Of course, if I am editing a question to add a snippet from existing non-snippet code, I'm out of luck, but that's a different scenario ;-). Commented Aug 5, 2020 at 13:55
  • @TylerH If your issue is with the wording of the buttons, that can be thought in the future. What I am proposing is to make the tool more accessible. You are saying that can't be done because it would be confusing, but it can be not confusing with the right words. I think it would be a good addition to the site. Do you agree with that or do you think it would be useless? If you think it would be useless, I'm ok with that, but if your issue is it would be confusing, I say it can be done in a way that would not be confusing.
    – Pedro Lima
    Commented Aug 5, 2020 at 13:57
  • @HereticMonkey, thank you. That's exactly what I meant.
    – Pedro Lima
    Commented Aug 5, 2020 at 13:58
  • 1
    I think such a feature would be unnecessary. There are already several easy ways to fiddle with stack snippet code both on and off the site.
    – TylerH
    Commented Aug 5, 2020 at 14:08

1 Answer 1

7

I think this will only be confusing.

If a user sees the snippet and sees there's a typo in it, they might press that proposed "Edit snippet" button, expecting to be able to edit the snippet in the question.

Editing a question's snippet is something you usually only do if you intend to (eventually) answer the question. I don't see the automatic draft as a bad thing...

1
  • 1
    I added the "(or another wording)" after the name of the button because I immediately saw the same problem you described, but I couldn't find another wording for that. I just guessed someone more qualified could. In my opinion, this would be a great improvement to the site and would be too sad to give up on it because the wording of a button.
    – Pedro Lima
    Commented Aug 5, 2020 at 13:37

You must log in to answer this question.

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