WordPress.org

Make WordPress Core

Opened 10 months ago

Last modified 10 months ago

#48890 new defect (bug)

Twenty Twenty: Customizer Controls Uncaught Errors

Reported by: fmixell Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 5.3
Component: Bundled Theme Keywords: has-patch has-screenshots
Focuses: javascript Cc:

Description

I noticed that the customizer.js file in the Twenty Twenty theme is loading in the customizer no matter if the theme is being edited or if a plugin is using the customizer. When using any plugin that takes advantage of the customizer you will see the attached type error.

Offending Code:

api.control( 'accent_hue_active' )

Uncaught TypeError: Cannot read property 'setting' of undefined. That's because plugins are loading their settings.

So far I've seen this cause issues with the jQuery UI Slider controls, they just won't load. Switching back to the TwentyNineteen theme or TwentySeventeen theme resolved the issue.

Adding a try catch block around this twenty twenty setting specific code solves the problem for me. Try catch is fully supported now so I think this could be a great, minimal code, solution to this bug.

Attachments (2)

48890.custom-setting-uncaught-typeerror.png (56.4 KB) - added by fmixell 10 months ago.
Screenshot of error
customize.diff (1.6 KB) - added by fmixell 10 months ago.
Patch

Download all attachments as: .zip

Change History (3)

@fmixell
10 months ago

Screenshot of error

@fmixell
10 months ago

Patch

#1 @dlh
10 months ago

Hi @fmixell, and welcome to WordPress Trac!

Can you provide a code snippet or a list of steps that can be used to replicate this bug?

A try/catch block would eliminate the error, but it would also mean that the Customizer logic in the theme might never run. If possible, I think it would be preferable to wrap the logic in the Customizer's built-in ready event so it will fire once the Customizer API is available. At a glance, Twenty Nineteen's customize-controls.js might be a useful guide to this approach.

Note: See TracTickets for help on using tickets.