revolution icon indicating copy to clipboard operation
revolution copied to clipboard

[Port to 3.x] Check if modx-content is defined before calling doLayout

Open jscaltreto opened this issue 3 years ago • 5 comments

What does it do?

Ports the fix from my previous PR https://github.com/modxcms/revolution/pull/14593 to 3.x

After upgrading to 3.0.1 the following issue resurfaced: occasionally widgets fail to load properly in the manager. I tracked it down to the call to doLayout() and found that sometimes when the listener gets called getCmp('modx-content') returned undefined. If I had to guess I'd say it's a race condition wherein sometimes the listener fires too early. Adding a check has resolved the issue entirely and I haven't encountered any ill effects.

Why is it needed?

Adds a check to verify modx-content is defined before calling doLayout

How to test

Intermittent issue of certain widgets not loading in the manager

Related issue(s)/PR(s)

Previously fixed in 2.x: https://github.com/modxcms/revolution/pull/14593

jscaltreto avatar Jul 24 '22 21:07 jscaltreto

Thank you for your contribution! Before your pull request can be reviewed, please sign the MODX Contributor License Agreement (CLA). This is to make sure MODX has your written permission to distribute projects containing your contributions under the appropriate license.

Please make sure the CLA has been signed for GitHub user(s): @jscaltreto

Once you've signed, please reply with @cla-bot check to verify and update the status of this pull request.

cla-bot[bot] avatar Jul 24 '22 21:07 cla-bot[bot]

@cla-bot check

jscaltreto avatar Jul 24 '22 21:07 jscaltreto

The cla-bot has been summoned, and re-checked this pull request!

cla-bot[bot] avatar Jul 24 '22 21:07 cla-bot[bot]

I don't have a way to reliably reproduce the issue. It seems to only happen intermittently with the migxdb input type, so it may be something specific to MIGX (CC @Bruno17) that isn't typically encountered in vanilla. When it happens, the result is that a Loading modal appears over the TV in the manager and it cannot be interacted with.

From the debugging I was able to do, the stack trace when this is encountered points back to this: https://github.com/Bruno17/MIGX/blob/7d6d8b8bd6e1d36f12c48c4d09f1572aac343c26/core/components/migx/templates/mgr/grids/default.grid.tpl#L72 So it would seem that it's possible for that to run before the modx-content component has been loaded. It throws an exception which prevents the TV from loading fully.

jscaltreto avatar Jul 26 '22 18:07 jscaltreto

Ok, yes, I've seen this issue myself on a couple of sites where migxdb is used. It's not something to address here in this PR. It may well be a timing issue. I might look into it a little further at some point... Thanks for the details!

smg6511 avatar Jul 26 '22 20:07 smg6511