Page MenuHomePhabricator

Uncaught TypeError: Cannot read property 'clone' of null when inserting language
Closed, ResolvedPublic1 Estimated Story Points

Description

Steps to reproduce:

  1. Type something in a LTR language (e.g., English).
  2. Decide that the next sentence should be RTL (e.g., Hebrew).
  3. Choose the "Language" item from the character styling menu.
  4. Try to change the language. Or just to get rid of the box.
  5. Give up and lose all work.

This looks related to T153356: Using browser functions to switch input direction is impossible in the new wikitext editor by @Amire80, but I think it's a separate bug.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript
AlexMonk-WMF renamed this task from Nothing happens when I click the "Insert" button in the "Language" box. It won't "Cancel", either. to Uncaught TypeError: Cannot read property 'clone' of null when inserting language.Dec 15 2016, 11:15 PM

This looks related to T153356

Not related.

I confirm this—it does nothing, and the inspector can't even be closed.

It does work correctly when some text is selected. Maybe when no text is selected the Language command should be just grayed-out.

IIRC, @Mooeypoo knows quite a lot about the Language command ;)

Change 330439 had a related patch set uploaded (by DLynch):
ui.AnnotationInspector: Don't assume previousSelection exists

https://gerrit.wikimedia.org/r/330439

Change 330441 had a related patch set uploaded (by DLynch):
ui.AnnotationInspector: In source mode, provide fallback insertionData

https://gerrit.wikimedia.org/r/330441

Jdforrester-WMF triaged this task as High priority.
Jdforrester-WMF set the point value for this task to 1.
Jdforrester-WMF moved this task from To Triage to TR0: Interrupt on the VisualEditor board.

To explain the issue, this is two things happening:

In source mode (NWE), the annotation inspector doesn't have access to the previousSelection property, which it assumes exists when the window closes. This causes the endless-loop of it trying to close, having an error and staying open, etc. Patch 330439 stops that assumption from being made.

When that's fixed, there's still nothing being inserted if you started with a collapsed selection. That's because NWE's annotation method doesn't cope well with empty annotations (they get boiled down to "" in the wikitext-generation). As such, patch 330441 provides a fallback in this case, mirroring the behavior of the italic/etc commands (which generate markup like `''Italic''` in the collapsed selection case).

(The latter patch probably removes all cases where the former is actually required, but I'm not 100% certain of that, so I figure it's better to be safe.)

Change 330439 merged by jenkins-bot:
ui.AnnotationInspector: Don't assume previousSelection exists

https://gerrit.wikimedia.org/r/330439

Change 330441 merged by jenkins-bot:
ui.AnnotationInspector: In source mode, provide fallback insertionData

https://gerrit.wikimedia.org/r/330441

Change 332879 had a related patch set uploaded (by Jforrester):
Update VE core submodule to master (6eba2e2)

https://gerrit.wikimedia.org/r/332879

Change 332879 merged by jenkins-bot:
Update VE core submodule to master (6eba2e2)

https://gerrit.wikimedia.org/r/332879