Opened 10 years ago
Closed 9 years ago
#37269 closed enhancement (fixed)
Introduce removed event for wp.customize.Values collection
| Reported by: | westonruter | Owned by: | westonruter |
|---|---|---|---|
| Priority: | normal | Milestone: | 4.9 |
| Component: | Customize | Version: | 3.4 |
| Severity: | normal | Keywords: | has-patch has-unit-tests commit |
| Cc: | Focuses: | javascript |
Description (last modified by )
Notifications were added to Customizer controls in #34893. Notifications are re-rendered when the control.notifications collection (a wp.customize.Values) has a wp.customize.Notification added or removed with the code as follows (via wp.customize.Control#initialize):
// After the control is embedded on the page, invoke the "ready" method. control.deferred.embedded.done( function () { /* * Note that this debounced/deferred rendering is needed for two reasons: * 1) The 'remove' event is triggered just _before_ the notification is actually removed. * 2) Improve performance when adding/removing multiple notifications at a time. */ var debouncedRenderNotifications = _.debounce( function renderNotifications() { control.renderNotifications(); } ); control.notifications.bind( 'add', function( notification ) { wp.a11y.speak( notification.message, 'assertive' ); debouncedRenderNotifications(); } ); control.notifications.bind( 'remove', debouncedRenderNotifications ); control.renderNotifications(); control.ready(); });
Notice the multi-line comment. We can't re-render the notifications at a remove event because this event gets triggered just before it is removed, somewhat unexpectedly. We should therefore introduce a removed event that gets triggered after the removal so that workarounds using debounce or defer aren't required.
Submitted patch should include unit test.
Change History (13)
This ticket was mentioned in Slack in #core by jorbin. View the logs.
10 years ago
This ticket was mentioned in Slack in #core-customize by celloexpressions. View the logs.
10 years ago
#8
@
10 years ago
- Keywords good-first-bug removed
- Owner set to
- Status new → assigned
@delawski nice. I added a code review comment.
#9
@
10 years ago
@westonruter Thank you for the review. I've added the condition as you suggested and also wrote additional unit test to cover case you've mentioned in the comment.
#10
@
10 years ago
- Keywords has-unit-tests commit added; needs-unit-tests removed
- Owner changed from to
- Status assigned → reviewing
Excellent. This can go into 4.8 as soon as trunk it open for enhancements.
#11
@
9 years ago
- Milestone Future Release → 4.9
- Status reviewing → accepted
I'm going to add this as part of #35210.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Can still make 4.7 if there's a patch, but we need a patch for now.