Fix "JQMIGRATE: jQuery.fn.offset() requires an element connected to a document" from maybeShowMetaDialog
Open, LowPublic0 Story Points

Description

When using VisualEditor, frequently seeing this:

JQMIGRATE: jQuery.fn.offset() requires an element connected to a document
OO.ui.PopupWidget.computePosition
OO.ui.mixin.FloatableElement.position

Not sure, but probably from this line:
https://github.com/wikimedia/oojs-ui/blob/bd15ed511c345db718dfdc6567224a6053e0fd36/src/widgets/PopupWidget.js#L502

Documentation

Release notes:
https://jquery.com/upgrade-guide/3.0/#breaking-change-invalid-input-to-the-offset-method

Migration legend:
https://github.com/jquery/jquery-migrate/blob/e967c3b98b/warnings.md#jqmigrate-jqueryfnoffset-requires-an-element-connected-to-a-document

Krinkle created this task.Jul 1 2017, 5:15 AM

Where do you see this? It sounds like a bug in the calling code, not in OOjs UI. You're not supposed to try to display popups that are not connected to the document.

It happens unconditionally on any load of VE for me, on Beta cluster. Here's the rest of the stack trace:

JQMIGRATE: jQuery.fn.offset() requires an element connected to a document

OO.ui.PopupWidget.computePosition
OO.ui.mixin.FloatableElement.position
OO.ui.mixin.FloatableElement.togglePositioning
OO.ui.PopupWidget.toggle
(jQuery.Promise#always)
ve.init.mw.DesktopArticleTarget.maybeShowMetaDialog
ve.init.mw.DesktopArticleTarget.surfaceReady
(setTimeout [async])
ve.init.mw.Target.setupSurface
ve.init.mw.Target.documentReady
ve..init.mw.ArticleTarget.documentReady
ve.init.mw.ArticleTarget.loadSuccess
ve.init.mw.DesktopArticleTarget.loadSuccess
(jQuery.Promise#done)
ve.init.mw.ArticleTarget.load
ve.init.mw.DesktopArticleTarget.activate
	// Show "switched" popup
	popup = new mw.libs.ve.SwitchPopupWidget( 'visual' );
	target.actionsToolbar.tools.editModeSource.toolGroup.$element.append( popup.$element );
	popup.toggle( true );

@matmarex This suggests it is attached somewhere before toggling. But perhaps the parent element is itself not yet attached here?

Restricted Application added a project: VisualEditor. · View Herald TranscriptJul 3 2017, 10:56 PM
Krinkle renamed this task from Fix "JQMIGRATE: jQuery.fn.offset() requires an element connected to a document" in PopupWidget to Fix "JQMIGRATE: jQuery.fn.offset() requires an element connected to a document" in SwitchPopupWidget.Jul 3 2017, 11:38 PM

I can't reproduce. Even in case where I get the "You have switched to visual editing" popup, this warning doesn't appear.

Krinkle closed this task as Invalid.Jul 6 2017, 3:16 AM

Hm.. me neither now. I'll assume something fixed it recently.

Deskana set the point value for this task to 0.Jul 6 2017, 12:53 PM
Krinkle reopened this task as Open.Jul 12 2017, 1:33 AM

I can't reproduce. Even in case where I get the "You have switched to visual editing" popup, this warning doesn't appear.

I can reproduce it again.

  1. On https://en.wikipedia.beta.wmflabs.org/, localStorage.clear(); sessionStorage.clear();, Log out
  2. Log in, and press Sandbox (red link for me) – https://en.wikipedia.beta.wmflabs.org/w/index.php?title=User:Krinkle/sandbox&action=edit

Same stack trace.

Krinkle renamed this task from Fix "JQMIGRATE: jQuery.fn.offset() requires an element connected to a document" in SwitchPopupWidget to Fix "JQMIGRATE: jQuery.fn.offset() requires an element connected to a document" from maybeShowMetaDialog.Jul 12 2017, 2:23 AM
Deskana triaged this task as Low priority.Jul 18 2017, 7:24 PM
Deskana moved this task from To Triage to TR1: Releases on the VisualEditor board.