A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://phabricator.wikimedia.org/T394078 below:

this.context is undefined in isScreenWideEnough

592 errors in last 7 days
Error: TypeError: this.context is undefined
https://logstash.wikimedia.org/goto/5a3f650994abfeea25c40521d24610f7

Stack trace:

at realtimepreview/RealtimePreview.js/RealtimePreview.prototype.isScreenWideEnough https://en.wikipedia.org/w/load.php?lang=en&modules=ext.wikiEditor.realtimepreview&skin=vector-2022&version=1tu3z:7:249
at realtimepreview/init.js/< https://en.wikipedia.org/w/load.php?lang=en&modules=ext.wikiEditor.realtimepreview&skin=vector-2022&version=1tu3z:1:636
at add https://en.wikipedia.org/w/load.php?lang=en&modules=mediawiki.base&skin=vector-2022&version=152ia:4:326
at realtimepreview/init.js https://en.wikipedia.org/w/load.php?lang=en&modules=ext.wikiEditor.realtimepreview&skin=vector-2022&version=1tu3z:1:210
at runScript https://en.wikipedia.org/w/load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector-2022:11:697
at execute/cssHandle/< https://en.wikipedia.org/w/load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector-2022:12:431
at flushCssBuffer https://en.wikipedia.org/w/load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector-2022:4:311

Steps to replicate the issue (include links if applicable):

What happens?:

What should have happened instead?:

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Event Timeline Comment Actions

This appears to happen when the addToToolbar handler isn't run quickly enough, and the auto-enable code runs first. I've not quite figured out why that happens, but the bug can be replicated by changing the order of the two bits of code:

diff --git a/modules/realtimepreview/init.js b/modules/realtimepreview/init.js
index 34d156ed..c893bf0c 100644
--- a/modules/realtimepreview/init.js
+++ b/modules/realtimepreview/init.js
@@ -8,6 +8,10 @@ mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
 
        const RealtimePreview = require( './RealtimePreview.js' );
        const realtimePreview = new RealtimePreview();
+       if ( realtimePreview.getUserPref() && realtimePreview.isScreenWideEnough() ) {
+               realtimePreview.setEnabled();
+               mw.hook( 'ext.WikiEditor.realtimepreview.inuse' ).fire( this );
+       }
        $textarea.wikiEditor( 'addToToolbar', {
                section: 'secondary',
                group: 'default',
@@ -20,8 +24,4 @@ mw.hook( 'wikiEditor.toolbarReady' ).add( function ( $textarea ) {
                        }
                }
        } );
-       if ( realtimePreview.getUserPref() && realtimePreview.isScreenWideEnough() ) {
-               realtimePreview.setEnabled();
-               mw.hook( 'ext.WikiEditor.realtimepreview.inuse' ).fire( this );
-       }
 } );

This changed order should work fine. There's no reason we want to have the button present before the auto-enabling happens. (Not that there's any actual need to change the order, so my patch doesn't do that.)


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4