Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 5 months ago

#53512 closed defect (bug) (fixed)

Twenty Seventeen: JS errors when displaying legacy widgets

Reported by: boniu91's profile Boniu91 Owned by: sergeybiryukov's profile 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 4 years ago.
53512.patch (806 bytes) - added by Clorith 4 years ago.

Download all attachments as: .zip

Change History (12)

@Boniu91
4 years ago

#1 @desrosj
4 years ago

  • Milestone changed from Awaiting Review to 5.8

Moving to the milestone to investigate.

#2 @desrosj
4 years 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.


4 years ago

@Clorith
4 years ago

#4 @Clorith
4 years 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
4 years ago

  • Keywords commit added

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

#6 @SergeyBiryukov
4 years 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
4 years 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.

#8 @sabernhardt
3 years ago

#41050 was marked as a duplicate.

#9 @sabernhardt
3 years ago

#48732 was marked as a duplicate.

#10 @flixos90
5 months ago

FYI this also fixed a problem with multisite compatibility (see #40338).

Note: See TracTickets for help on using tickets.