WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#42330 closed defect (bug) (fixed)

Customizer errors when control is associated with non-existing section

Reported by: prajaktag Owned by: westonruter
Milestone: 4.9 Priority: normal
Severity: normal Version: 4.9
Component: Customize Keywords: has-patch
Focuses: Cc:

Description (last modified by westonruter)

Get this js error while creating new menu from themes customiser - Uncaught TypeError: Cannot read property 'open' of undefined

Here is screenshot - https://goo.gl/gVaxBU

  • Uncaught TypeError: Cannot read property 'open' of undefined

The theme is One Page X with beta 3 wordpress.

Attachments (1)

42330.diff (1.7 KB) - added by westonruter 4 years ago.
https://github.com/xwp/wordpress-develop/pull/293

Download all attachments as: .zip

Change History (10)

#1 @westonruter
4 years ago

  • Milestone changed from Awaiting Review to 4.9

The error when attempting to add a nav menu item is probably a side effect of the first error related to unsync being undefined.

#2 @westonruter
4 years ago

  • Description modified (diff)

#3 @SergeyBiryukov
4 years ago

  • Component changed from General to Customize

#4 @westonruter
4 years ago

The reason for the error is that theme is doing $wp_customize->remove_section( 'header_image') and $wp_customize->add_section( 'background_image'), but it is not subsequently changing the section for the controls that were in the header_image section. So the background_repeat control is getting added to the Customizer without a containing section. Because of this, the embedded deferred is never resolved because of this: https://github.com/WordPress/wordpress-develop/blob/a33d615/src/wp-admin/js/customize-controls.js#L3578-L3590

And since the control.linkElements() is currently being called once embedded is deferred, the elements then never get created. And this is why the error is happening.

#5 @westonruter
4 years ago

  • Summary changed from JS error while adding new item to menu using theme customiser. to Customizer errors when control is associated with non-existing section

#6 @westonruter
4 years ago

  • Keywords has-patch needs-testing added
  • Owner set to westonruter
  • Status changed from new to accepted

This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.


4 years ago

#8 @rinkuyadav999
4 years ago

  • Keywords needs-testing removed

Hi @westonruter

This patch fixed both issues. Menu, Theme Changes in customize.

Thanks

#9 @westonruter
4 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 42024:

Customize: Link elements prior to embedding to prevent possible errors when a control is associated with a non-existent section.

Fixes issue specifically with attempting to access an orphaned control's elements immediately after it has been added. Normally this would not happen because a control would not be registered without a section, and also a control should only be interacted with once its embedded deferred has been resolved.

Also harden logic for gathering list of deferred setting IDs.

See #37964.
Fixes #42330.

Note: See TracTickets for help on using tickets.