Page MenuHomePhabricator

VisualEditor: Inserting an existing reference in the first paragraph in Firefox puts it at the start of the paragraph, not where the cursor is
Closed, ResolvedPublic

Description

When an existing reference is inserted, it is put at the start of the paragraph the cursor is currently in, regardless of where it is in that paragraph. This has happened to me while I was attempting to use in a paragraph a reference that was already used in that paragraph: the reference got inserted at the start of the paragraph and I was not able to move it. I tried again some times but it still did not work and I had to use the wikitext editor.


Version: unspecified
Severity: normal

Details

Reference
bz52159

Event Timeline

I did only a quick test, and could not reproduce this bug. Could you give more detailed instructions?

I have done similar manipulations in other articles at some moments, and it seems it sometimes works and sometimes doesn't. There are many things that are strange concerning how the existing references system works.

Regardless, I set up a sandbox page on my user space, added a reference and then tried to re-use that reference using the VisualEditor. The reference was added at the start of the paragraph. I've done some more experimenting, and I've written steps to reproduce the bug; the first block reproduces the bug and the following blocks are other experimentations that give more strange results.

  1. Go to [[User:Rastus Vernon/VisualEditor Sandbox]].
  2. Edit the page with the VisualEditor.
  3. Click somewhere in the first paragraph, not at the start.
  4. Click on the reference button and re-use the reference (there is only one).
  5. Note how the reference was inserted at the start of the paragraph instead of being inserted where your cursor was.
  1. Click in another paragraph, not at the start.
  2. Insert the same reference again.
  3. Note how the reference was inserted at the right position.
  1. Perform steps 7 and 8 again.
  2. Note how it was again inserted at the right position, although the reference is already in that paragraph.
  1. Try inserting it again in the first paragraph.
  2. Note how it still inserts it at the start of the paragraph instead of inserting it in the right location.
  1. Be confused because you don't understand anything about this inconsistent behavior.

At en.wp WhatamIdoing reports:
I was just trying to add the ref to the other sentences. It misplaced two copies at the start of the paragraph when I wanted one at the end of the first line of the first paragraph (perhaps I clicked too high on the top line of the edit window?). After I removed those, I couldn't add any more. Clicking the ref button did nothing." He gives the following URL:
https://en.wikipedia.org/w/index.php?title=Swing_%28seat%29&diff=568557479&oldid=568556853

AFAICT this only happens in the first paragraph (and only in Firefox).

This is throwing an error in Rangy:

TypeError: sel.nativeSelection is null
sel._ranges.length = sel.rangeCount = sel.nativeSelection.rangeCount;

… but for some reason I can't get Firebug to give me a trace.

Change 80056 had a related patch set uploaded by Esanders:
Preserve selection when inserting references

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

Change 80056 merged by jenkins-bot:
Preserve selection when inserting references

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

Should now be fixed; we will deploy this earlier than scheduled, later today.

  • Bug 52594 has been marked as a duplicate of this bug. ***