WordPress.org

Make WordPress Core

Opened 5 weeks ago

Closed 5 weeks ago

#53512 closed defect (bug) (fixed)

Twenty Seventeen: JS errors when displaying legacy widgets

Reported by: Boniu91 Owned by: SergeyBiryukov
Milestone: 5.8 Priority: normal
Severity: normal Version:
Component: Bundled Theme Keywords: has-patch commit
Focuses: Cc:

Description

WordPress 5.8-beta3-51230
Browser 91.0.4472.114
Theme Twenty Seventeen

Steps to reproduce:

  1. Downgrade to 5.7.x WordPress using the Beta Tester plugin
  2. Add a couple of widgets, make sure that Image widget is also added
  3. Upgrade to 5.8-beta
  4. Go to the Appearance > Widgets area and open JS console, see errors
  5. Click on the legacy Image widget, see another error

Attachments (2)

JS errors.PNG (78.1 KB) - added by Boniu91 5 weeks ago.
53512.patch (806 bytes) - added by Clorith 5 weeks ago.

Download all attachments as: .zip

Change History (9)

@Boniu91
5 weeks ago

#1 @desrosj
5 weeks ago

  • Milestone changed from Awaiting Review to 5.8

Moving to the milestone to investigate.

#2 @desrosj
5 weeks ago

  • Keywords needs-patch added

I've been able to reproduce this one, and it seems to happen when any widgets are found in sidebars, not just the Image widget.

This ticket was mentioned in Slack in #core by jeffpaul. View the logs.


5 weeks ago

@Clorith
5 weeks ago

#4 @Clorith
5 weeks ago

  • Keywords has-patch added; needs-patch removed

This appears to be related to the assets/js/global.js file in the theme, which expects markup to exist on the page if sidebars are defined, but that markup is missing since only the widget it self and headers/footers of the page are loaded in the iframe used to display legacy widgets (widgets added prior to WordPress 5.8).

53512.patch ensures the $sidebar variable is defined, and as it returns a jQuery array of objects (as it is defined using .find()), it also checks that there is at least one entry in that array. If neither of these cases ring true, it will return without trying to perform manipulations on the meta area of the theme.

#5 @desrosj
5 weeks ago

  • Keywords commit added

Thanks @Clorith! I think 53512.patch makes sense. Marking for commit.

#6 @SergeyBiryukov
5 weeks ago

  • Component changed from Widgets to Bundled Theme
  • Summary changed from JS errors when displaying legacy widgets using Twenty Seventeen theme to Twenty Seventeen: JS errors when displaying legacy widgets

#7 @SergeyBiryukov
5 weeks ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 51257:

Twenty Seventeen: Avoid JS errors when displaying legacy widgets.

Make sure the $sidebar variable is defined and has at least one entry in the array, before adding the .below-entry-meta class to elements below the entry meta.

Previously, the theme expected sidebar markup to exist on the page if sidebars are defined, but that markup is missing since only the widget itself and headers/footers of the page are loaded in the iframe used to display legacy widgets (widgets added prior to WordPress 5.8).

Props Clorith, Boniu91, desrosj.
Fixes #53512.

Note: See TracTickets for help on using tickets.