# Stop focusing editor when clicking “run code snippet”

When creating a post that has one or more code snippets and I click "Run code snippet" the page scrolls back to the post's textarea. Since the code snippets are normally at the end of posts, this means each time I test the code I need to manually scroll all the way back to where I was.

This does not happen when editing a post.

Running the code is a frequent action when ensuring that code is free of bugs and at a standard I find acceptable. The need to scroll back to the result of the run is a major interruption of my work flow.

I find this to be the single most annoying feature on Stack Exchange sites. Am I the only one that finds this feature annoying?

I request that this feature be removed, or that there be a way to prevent this from happening.

• Thanks for logging this. It may need to be logged on MSE. There is a similar zombie post on MSO – Sᴀᴍ Onᴇᴌᴀ Jan 20 at 19:24
• If a feature-request requests to remove a feature, was the feature still a feature or actually a bug? – Mast Jan 20 at 20:23
• @Mast, I think the term of art is "Misfeature". I have to admit to being surprised how old the word is, though... – Toby Speight Jan 20 at 21:26
• I've been using this userscript for ages for this – CertainPerformance Jan 21 at 4:56
• This may be fixed with the new Stacks editor. – Peilonrayz Jan 26 at 21:04

You can stop this in two ways. To get the code to run on all pages automatically you can convert these to userscript manager scripts.

1. Disable the onclick events on the preview.

$(".wmd-preview").off("click")  2. Wrap the buttons' onclick events to stop propagation. $(".snippet button.s-btn, .snippet .popout-code")
.each((_, e) => {
const handlers = ($._data(e, "events").click ?? []).map(c => c.handler);$(e).off("click").on("click", (event, ...args) => {
event.stopPropagation();
handlers.forEach(h => h(event, ...args));
});
})

• Thanks, I already have a extension that does similar, I am migrating it to v3.0 (Manifest version 3) and dropped this option, forgetting how annoying it is. I posted because I think that it should be fixed for everyone. – Blindman67 Jan 21 at 1:38
• @Blindman67 Ah! I like to click text when I'm reading, and so when I'm proofreading my answers... Aagh!!! – Peilonrayz Jan 21 at 2:03