4
\$\begingroup\$

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.

\$\endgroup\$
6
  • 2
    \$\begingroup\$ Thanks for logging this. It may need to be logged on MSE. There is a similar zombie post on MSO \$\endgroup\$ – Sᴀᴍ Onᴇᴌᴀ Jan 20 at 19:24
  • 2
    \$\begingroup\$ If a feature-request requests to remove a feature, was the feature still a feature or actually a bug? \$\endgroup\$ – Mast Jan 20 at 20:23
  • \$\begingroup\$ @Mast, I think the term of art is "Misfeature". I have to admit to being surprised how old the word is, though... \$\endgroup\$ – Toby Speight Jan 20 at 21:26
  • \$\begingroup\$ I've been using this userscript for ages for this \$\endgroup\$ – CertainPerformance Jan 21 at 4:56
  • \$\begingroup\$ Related, highly-upvoted Q on SO about this: meta.stackoverflow.com/questions/295666/… \$\endgroup\$ – CertainPerformance Jan 21 at 5:13
  • 1
    \$\begingroup\$ This may be fixed with the new Stacks editor. \$\endgroup\$ – Peilonrayz Jan 26 at 21:04
2
\$\begingroup\$

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));
            });
        })
    
\$\endgroup\$
2
  • \$\begingroup\$ 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. \$\endgroup\$ – Blindman67 Jan 21 at 1:38
  • \$\begingroup\$ @Blindman67 Ah! I like to click text when I'm reading, and so when I'm proofreading my answers... Aagh!!! \$\endgroup\$ – Peilonrayz Jan 21 at 2:03

You must log in to answer this question.

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