Page MenuHomePhabricator

Can't remove lines with syntax highlight on Android
Closed, ResolvedPublic2 Estimated Story PointsBUG REPORT

Description

How to reproduce:

  • From a mobile device go to a template page, i.e. en:Template:Template sandbox
  • Change to desktop view if necessary.
  • Edit it
  • Activate syntax highlight with the pencil button, if necessary.
  • Insert new lines anywhere.
  • Try to remove them with backspace key.

Actual results:

  • Cursor moves out of edit box and it does nothing.

Reported with:

  • Chrome 91 on Android 10
  • Chrome 90 on Android 11
  • Chrome 91 on Android Oreo

Initial reporter suspects it happens since the introduction of line numbering feature.

Event Timeline

Hi, which editor software is being used? See https://www.mediawiki.org/wiki/Editor

This looks unrelated to mobile apps but seems to be about web browsers.

The WikiEditor. With 2017 wikitext editor it does not work either, but it has a different behavior due to T212680 or related problems. I think syntax highlight by extension CodeMirror is only used with these editors.

FYI, I can not reproduce this in Chrome 91 on Android 10.

@Vriullop, where was the "initial report" posted? On a wiki? Can you please provide a link?

WMDE-Fisch moved this task from Sprint Backlog to Doing on the WMDE-TechWish-Sprint-2021-06-23 board.

First revelation to this from my side:

  • Some mobile browser will always return a 229 keycode on keydown and keyup events. So if you try do use one of these in your code you can not rely on the keycode. That's at least whats happening on my mobile device. Instead you should try to use keypress, that will always give the right keycode. [1]
  • There's this line in the CodeMirror codebase, where a backspace-keypress is thrown away [2]
  • And one line, where there's a backspace - keydown manually triggered for Android Chrome [3]

[1] https://social.msdn.microsoft.com/Forums/en-US/d9ac5d52-55f5-4e8f-b074-22323834a09c/keydown-event-always-returns-keycode-229?forum=vssmartdevicesvbcs
[2] https://gerrit.wikimedia.org/g/mediawiki/extensions/CodeMirror/+/daeaae012cd637ff34978d5410b9cd252373e9d4/resources/lib/codemirror/lib/codemirror.js#7252
[3] https://gerrit.wikimedia.org/g/mediawiki/extensions/CodeMirror/+/daeaae012cd637ff34978d5410b9cd252373e9d4/resources/lib/codemirror/lib/codemirror.js#8994

I played with this for a while now including trying to understand it better and fix it. The bug is obviously upstream in the library since it also appears on the demo page for CodeMirror[1]. There are also already some tickete for issues around mobile support including one umbrella ticket that lists the backspace bug[2].

It can be expected, that most of these issues will not be dealt with in version 5 of CodeMirror and will hopefully be fixed with version 6. Until then I guess we could thinking about disabling the feature for mobile browsers.

[1] e.g.: https://codemirror.net/demo/marker.html
[2] https://github.com/codemirror/CodeMirror/issues/6145

This will be solved temporary by disabling the feature for mobile devices in T285660: CodeMirror: Disable line numbers for mobile devices.
The proper solution should be applied by doing T259059: Upgrade to CodeMirror 6.

I will close this ticket for now.