Encountered this JavaScript error - see attached patch.

Uncaught TypeError: Cannot read property 'top' of undefined
    at n.highlightBlock (LayoutView.js?v=8.2.7:320)
    at n.addBlock (LayoutView.js?v=8.2.7:536)
    at n.addBlockPlugin (AppView.js?v=8.2.7:266)
    at _ (backbone.js:370)
    at m (backbone.js:356)
    at f (backbone.js:155)
    at n.l.trigger (backbone.js:346)
    at Object.attach (panels_ipe.js?v=8.2.7:33)
    at Object.Drupal.attachBehaviors (drupal.js?v=8.2.7:168)
    at Drupal.AjaxCommands.insert (ajax.js?v=8.2.7:1084)

Comments

chrishks created an issue. See original summary.

stephaneq’s picture

Version: 8.x-3.0-beta5 » 8.x-4.x-dev
Status: Active » Needs review

Had the same issue with latest version, patch works fine

antroxim’s picture

Assigned: Unassigned » antroxim
antroxim’s picture

StatusFileSize
new616 bytes

Provided patch removes the error from console but it also breaks functionality. When new block is added to top region trough IPE and window scroll position is lower this bug appears on attempt to scroll page up to show where block was placed. Implemented patch that prevents JS error while not affecting scroll.

Status: Needs review » Needs work

The last submitted patch, 4: js_error_in_ipe-2862959-4.patch, failed testing. View results

antroxim’s picture

StatusFileSize
new502 bytes
antroxim’s picture

Status: Needs work » Reviewed & tested by the community
samuel.mortenson’s picture

Status: Reviewed & tested by the community » Needs work

Calling this.model.fetch will make a new HTTP request, which is not desirable as at this point in execution we already have the layout model. The error is being thrown in the highlightBlock function, so I would expect a fix to be there.

mohit_aghera’s picture

Assigned: antroxim » Unassigned
Status: Needs work » Needs review
StatusFileSize
new0 bytes

I am not able to figure out why $block with particular UUID is not present in dom.
However, by adding validation for $block is not empty, it doesn't throw an error in console and continues execution.

Attaching small patch for it.

mohit_aghera’s picture

StatusFileSize
new471 bytes

Updating correct patch.

mikemadison’s picture

Status: Needs review » Reviewed & tested by the community

I can confirm the presence of the error before the patch, and the after it was applied it seems fine.

looks good to me!

  • japerry committed 54d1594 on 8.x-4.x authored by mohit_aghera
    Issue #2862959 by antroxim, mohit_aghera, chrishks: JS error in IPE -...
japerry’s picture

Status: Reviewed & tested by the community » Fixed

Sounds good. Fixed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.