Page MenuHomePhabricator

VisualEditor: Problems changing image type from Thumbnail to Basic when surrounded by images with images in captions
Closed, ResolvedPublic8 Estimated Story Points

Description

Go to this page:

https://test2.wikipedia.org/w/index.php?title=User:RYasmeen_(WMF)/sandbox&oldid=87309

Change the first image from Thumbnail to Basic and click on "Apply Changes"
The following error appears in the console and cannot save page or cancel editing the page with VE.

Uncaught Error: Offset could not be translated to a DOM element and offset: 55


Version: unspecified
Severity: normal

Details

Reference
bz66604

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 3:09 AM
bzimport set Reference to bz66604.

The problem seems to be in ve.ce.Document.prototype.getNodeAndOffset() where the stack ends up empty but the element is not a slug.

I am pretty certain this happens due to the image with the complex caption that includes {{Cite}} <math> <ref> and another image inside it. My attempts to sanitize the wikitext and try everything one-by-one failed when I added that piece:

[[File:MO-supp-K.svg|thumb]]
[[File:MO-supp-K.svg|thumb]]
[[File:IMA-johnson1.jpg|right|frameless|caption
<ref>{{Cite web|url = http://yahoo.com|title = }}</ref>

<ref>reference</ref>{{Citation needed}}

<math>\pi</math>
[[File:S.M.R.JPG|thumb]]

{{Cite web|url = http://yahoo.com|title = }}

]]

This is the minimum wikitext required to reproduce this issue:
[[File:MO-supp-K.svg|thumb]]
[[File:IMA-johnson1.jpg|right|frameless|

[[File:S.M.R.JPG|thumb]]
{{Cite web|url = http://yahoo.com|title = }}

]]

You can try on this page:
https://test2.wikipedia.org/wiki/Test66604?veaction=edit

Found the steps to reproduce it from VE :D

1.Open a page with VE
2.Insert an image, keep it thumbnail-right
3.Go to next line of the added image by pressing enter
4.Add another image on the next line, make it frameless right
5.Now in the caption of the second image : Add another image and go to the next line of this image by pressing enter
6.Add anything on the next line of the caption
7.Apply changes
8.Save Page
7.Reopen the page
8.Try to make the first image Thumbnail to Basic

Observed Result:

Uncaught Error: Offset could not be translated to a DOM element and offset: 55
appears in the console and cannot cancel the edit or save the page in VE

I... can no longer reproduce this. I tried the steps in comment 3 as well as the wiki page in comment 2. Maybe this got fixed by Ed's selection-after-deletion fix? Because when we change an image from block to inline, we delete the old image and insert a new one.

Marking as theoretically fixed, then. :-)

On test 2 wiki:
the first case still throws an exception
the second 'minimal' case results in the image being deleted

first case works perfectly in master
second case still results in the image being deleted

Change 144004 had a related patch set uploaded by Esanders:
Skip over nested handlesOwnChildren nodes in getRelativeOffset

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

Change 144004 merged by jenkins-bot:
Skip over nested handlesOwnChildren nodes in getRelativeOffset

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

Change 144136 had a related patch set uploaded by Esanders:
Fixes to getRelativeOffset and getRelativeRange

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

Change 144136 merged by jenkins-bot:
Fixes to getRelativeOffset and getRelativeRange

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

Now if I follow the minimal wikitext or the steps to reproduce in a page and try to change the first image from thumbnail to Basic, it moves the image inside the caption of the second image.

Is that how we want it now?

Jdforrester-WMF set Security to None.
Jdforrester-WMF edited a custom field.
Deskana lowered the priority of this task from Medium to Lowest.Apr 12 2018, 4:24 PM
matmarex subscribed.

This seems to work correctly now. I can't reproduce any of the issues described here.