TGMPA / TGM-Plugin-Activation

TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins). It allows your users to install, update and even automatically activate plugins in singular or bulk fashion using native WordPress classes, functions and interfaces. You can reference bundled plugins, plugins from the WordPress Plugin Repository or even plugins hosted elsewhere on the internet.
http://tgmpluginactivation.com/
GNU General Public License v2.0
1.76k stars 429 forks source link

Uncaught TypeError: Cannot read property 'focus' of undefined #660

Open emiluzelac opened 7 years ago

emiluzelac commented 7 years ago

Hey, folks, just reporting what may or may not be TGMPA issue, but it's worth a look.

This is a freshly generated TGMPA and error displays only if a preview is clicked on. Now, this error goes away on a refresh:

http://envato.d.pr/rqQH/1sQhSeR6

My convo with Gary:

Me:

Hey bud, just noticed this while previewing the plugin and not sure if this is core or TGMPA related, here's the scenario:

Gary:

Might be a combination - core trying to return focus, incorrectly assuming it was only opened from a particular page / not checking that element to focus on exists first?

Thanks, Emil

GaryJones commented 7 years ago

@emiluzelac Could you please paste the error message here, for reference?

From what I saw, it looked the error was thrown on the closing of the preview, not on the opening.

emiluzelac commented 7 years ago
Uncaught TypeError: Cannot read property 'focus' of undefined
http://localhost/wp-admin/load-scripts.php?c=1&load%5B%5D=hoverIntent,common,admin-bar,underscore,wp-util,wp-a11y,updates,jquery-ui-core,thickbox,plugin-install,svg-painter,heartbeat,wp-&load%5B%5D=auth-check&ver=4.7.3 line 364
jrfnl commented 7 years ago

I've just tried to reproduce this issue and I do get a JS error on closing the plugin information overlay, but the error I receive is a different one.

Tested on WP 4.8, 4.7.5 and 4.6.6

TypeError: $focusedBefore is undefined
http://localhost/wp-admin/js/plugin-install.js?ver=4.8 line 66

@emiluzelac Are you using any plugins which may concatenate js files which could cause the difference in the message ? If not, could you please test this again yourself and tell me exact steps to reproduce your issue ?

To be honest though, I suspect this is a WP Core issue as TGMPA uses the Core functionality for creating and handling the overlay. All the same, it might be that we can pass a parameter somewhere to get rid of the error, but I'll need to look into that more in-depth.

emiluzelac commented 7 years ago

The steps are the same as on the video above, the basics.

Installed plugins:

On Sat, Jul 1, 2017 at 10:11 PM, Juliette notifications@github.com wrote:

I've just tried to reproduce this issue and I do get a JS error on closing the plugin information overlay, but the error I receive is a different one.

Tested on WP 4.8, 4.7.5 and 4.6.6

TypeError: $focusedBefore is undefinedhttp://localhost/wp-admin/js/plugin-install.js?ver=4.8 line 66

@emiluzelac https://github.com/emiluzelac Are you using any plugins which may concatenate js files which could cause the difference in the message ? If not, could you please test this again yourself and tell me exact steps to reproduce your issue ?

To be honest though, I suspect this is a WP Core issue as TGMPA uses the Core functionality for creating and handling the overlay. All the same, it might be that we can pass a parameter somewhere to get rid of the error, but I'll need to look into that more in-depth.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/TGMPA/TGM-Plugin-Activation/issues/660#issuecomment-312468120, or mute the thread https://github.com/notifications/unsubscribe-auth/ABs6zuR5X48trlfj8NyMox_o7itXZnv4ks5sJwpggaJpZM4M_l_s .

jrfnl commented 7 years ago

Ran some more tests, this time with SCRIPT_DEBUG turned off (my original test setup had it turned on while I think yours doesn't) and again, I receive a different error from the one you are getting (tested on WP 4.7, 4.8):

TypeError: f is undefined
http://tgmpa3.localdev/wp-admin/load-scripts.php?c=0&load%5B%5D=hoverIntent,common,admin-bar,underscore,wp-util,wp-a11y,updates,jquery-ui-core,thickbox,plugin-install,svg-painter,heartbeat,wp-&load%5B%5D=auth-check,wp-ajax-response&ver=4.8 line 364
emiluzelac commented 7 years ago

That would be correct Juliette, by the nature of my job debug is always on.

Thanks for trying!

On Sun, Jul 2, 2017 at 7:02 PM Juliette notifications@github.com wrote:

Ran some more tests, this time with SCRIPT_DEBUG turned off (my original test setup had it turned on while I think yours doesn't) and again, I receive a different error from the one you are getting (tested on WP 4.7, 4.8):

TypeError: f is undefinedhttp://tgmpa3.localdev/wp-admin/load-scripts.php?c=0&load%5B%5D=hoverIntent,common,admin-bar,underscore,wp-util,wp-a11y,updates,jquery-ui-core,thickbox,plugin-install,svg-painter,heartbeat,wp-&load%5B%5D=auth-check,wp-ajax-response&ver=4.8 line 364

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/TGMPA/TGM-Plugin-Activation/issues/660#issuecomment-312524988, or mute the thread https://github.com/notifications/unsubscribe-auth/ABs6zuqPMll08f23QxVUV1Y-OrfUK7Ioks5sKC-IgaJpZM4M_l_s .

jrfnl commented 7 years ago

debug is always on.

Except it wasn't, at least not script debug.

Would you mind testing with define( 'SCRIPT_DEBUG', true ); added to wp-config.php and letting me know what the error is you see then ? Just want to make sure I'm actually looking at the correct error before attempting a patch.

emiluzelac commented 7 years ago

Alright I'll check later on.

On Mon, Jul 3, 2017 at 6:41 AM Juliette notifications@github.com wrote:

debug is always on.

Except it wasn't, at least not script debug.

Would you mind testing with define( 'SCRIPT_DEBUG', true ); added to wp-config.php and letting me know what the error is you see then ? Just want to make sure I'm actually looking at the correct error before attempting a patch.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/TGMPA/TGM-Plugin-Activation/issues/660#issuecomment-312623931, or mute the thread https://github.com/notifications/unsubscribe-auth/ABs6ztJd1IX0ITnOCDNn9VcBuTQmXHiHks5sKNN1gaJpZM4M_l_s .