Page MenuHomePhabricator

Move the default OOUI overlay and window manager inside the MediaWiki teleport target
Closed, ResolvedPublic

Description

As suggested by @Jdlrobson in T339058#9201151, we should move the default OOUI overlay and window manager (OO.ui.getDefaultOverlay() and OO.ui.getWindowManager()) inside the MediaWiki teleport target (require( 'mediawiki.page.ready' ).teleportTarget). This will allow skins to style the dialogs/dropdowns/etc. provided by OOUI, Codex and any future libraries with just one CSS override (or one line of JS). See T347199: Apply skin body styles to teleported elements for context.

We could add an overridable method in OOUI, which would be used by these two methods, and overridden in MediaWiki here: https://gerrit.wikimedia.org/g/mediawiki/core/ /master/resources/src/ooui-local.js. (I considered just overriding these two methods in MediaWiki directly, to avoid depending on a new OOUI release, but it was ugly, and there's no hurry.)

OOUI itself shouldn't have any references to MediaWiki teleport target, since it's supposed to be independent of MediaWiki.

Related Objects

Event Timeline

Change 963846 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[oojs/ui@master] Add OO.ui.getTeleportTarget() to allow it to be overridden

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

Change 963847 had a related patch set uploaded (by Bartosz Dziewoński; author: Bartosz Dziewoński):

[mediawiki/core@master] Use standard 'teleportTarget' for OOUI

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

Change 963846 merged by jenkins-bot:

[oojs/ui@master] Add OO.ui.getTeleportTarget() to allow it to be overridden

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

Change 964977 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/skins/Vector@master] Simplify teleport styles

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

Change 963847 merged by jenkins-bot:

[mediawiki/core@master] Use standard 'teleportTarget' for OOUI

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

So WindowManager, PopupElement, etc. all need to be attached to OO.ui.getTeleportTarget() instead of <body> to have the proper styling now? That seems like such a breaking change it deserves to be on at least wikitech-l, if not also Tech News (especially given we don't have the frontend mailing list yet). Documentation on MWWiki and gadgets also need fixing.

@Nardog When it comes to PopupElement etc. that has always been the case, except that before we had OO.ui.getTeleportTarget(), you had to attach your popups to OO.ui.getDefaultOverlay() (or inside #mw-content-text etc.), otherwise they would have the wrong font size in most MediaWiki skins.

When it comes to WindowManager, it actually had special styling before so it worked when attached to <body>, and I made a mistake in removing it. It has been restored now in https://phabricator.wikimedia.org/T350544. Sorry about that (and sorry I didn't see your comment earlier).

The documentation at https://www.mediawiki.org/wiki/OOUI/Concepts#Overlays is correct, as far as I can tell. If you point me to anything that is wrong or unclear, I'll fix it.

@matmarex No problem! One thing that remains unclear to me is when one should attach a WindowManager to OO.ui.getTeleportTarget() and when to <body>. I see T350467 has not been undone, so is the recommended practice going forward to use the teleport target? Or is there something specific about these elements that warrants the use of the teleport target?

Yes, always attach them to OO.ui.getTeleportTarget() from now on. In the past we've had a hard time keeping the special WindowManager styles in sync with the normal styles for the content, particularly on Vector (this was one of my motivations for this change), so if that happens again, you'll avoid problems.