4
$\begingroup$

A few days ago I tried to use the citation helper from my mobile phone (Nexus 6p with Firefox and the full site interface), and everything worked just fine.

But now I tried to load it, and it kept insisting that touch devices are not supported.

In a world where there is an increasing use of hand-held devices, and seeing how it worked fine just a few days ago, is there any sound rationale behind this decision?

$\endgroup$
  • 1
    $\begingroup$ I wasn't sure if this is a bug or a feature, so I used both. Please retag appropriately. $\endgroup$ – Asaf Karagila May 5 '17 at 6:54
  • $\begingroup$ I have yet to see the citation helper work anywhere. $\endgroup$ – Emil Jeřábek supports Monica May 5 '17 at 7:55
  • $\begingroup$ Odd. I used it several times here and on math.SE (since its revamp, that is). $\endgroup$ – Asaf Karagila May 5 '17 at 8:05
  • $\begingroup$ Actually, now I finally found a browser where it does work: on my mobile phone. So, while the software appears fragile, it does not seem to discriminate against hand-held devices in particular. $\endgroup$ – Emil Jeřábek supports Monica May 5 '17 at 11:13
  • $\begingroup$ Perhaps you can give us the details, then? $\endgroup$ – Asaf Karagila May 5 '17 at 13:26
2
$\begingroup$

This appears to be the same "bug" that also affects the Stack Snippet editor on Stack Overflow. Basically, all "external editing tools" are disabled on touch devices, regardless of whether they actually work on such devices or not. That includes the snippet editor on SO, the citation helper here, and basically all other custom editor buttons on any SE sites.

(If you notice any such buttons working on a touchscreen device, that probably means that the code that tries to disable them fails to work on that device for some reason. One possible explanation could be that your browser is configured not to actually generate touch events, and thus the SE editor cannot tell that it's running on a touchscreen device.)

Anyway, my SOUP user script / browser extension contains a client-side hack to work around this restriction, although it's currently only included in the experimental development version. Once I get around to releasing the next stable version of SOUP, you could install it on your touch device, assuming that your browser actually supports user scripts or can run SOUP as an extension. (Unfortunately, most mobile browsers don't. I've tested the SOUP Firefox extension on Firefox Mobile, though, and it appears to run fine there.)

Of course, user scripts like SOUP can't actually fix the root cause of such bugs, they just hide the problem from those few users motivated enough to install them. A proper solution would be for Stack Exchange developers to fix the Markdown editor code so that custom editor buttons aren't needlessly disabled on touch devices.


Ps. It does occur to me that MO is a bit of a special case, since you're allowed to include custom JS on the site. Thus, in principle, you could use that feature to hack around the unnecessary touch device check, and so enable the citation helper on mobile devices. Just as an illustrative example, here's some (only briefly tested!) JS code that should achieve this:

// hook the Markdown editor code to let the citation helper work on touch devices
StackExchange.ifUsing('editor', function () {
    StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
        $('#post-editor' + postfix).on(
            'touchstart', '.wmd-cite-button > span',
            function () { $(this).off('touchend') }
        );
    });
});
// just in case, also fix any editor instances that have already been initialized
$('.post-editor').on(
    'touchstart', '.wmd-cite-button > span',
    function () { $(this).off('touchend') }
);

This is based on the code I'm currently using in SOUP, but somewhat streamlined to only do the bare minimum needed to enable the citation helper on touch devices. (The SOUP code also fixes the SO snippet editor, which is somewhat more complicated.)

Of course, if you were to actually submit this code to SE for inclusion in the custom JS footer, my guess is they'd just get somebody to fix this bug properly instead. Then again, that would actually be the ideal outcome, anyway...

$\endgroup$

You must log in to answer this question.

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