Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#28581 closed defect (bug) (fixed)

Theme browser sidebar expand/collapse only works on every other theme

Reported by: helen's profile helen Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 4.0 Priority: normal
Severity: normal Version:
Component: Themes Keywords: has-patch commit
Focuses: javascript Cc:



  • Go to add themes.
  • Open up the details view.
  • Expand/collapse the sidebar. Note that it works, even multiple times.
  • Navigate to the next theme with either arrow or by clicking the next button.
  • Try to expand/collapse the sidebar. It doesn't work.
  • Navigate to the next theme. Expand/collapse does work.
  • Rinse and repeat.

You can substitute closing the details view for navigating next/prev as well, same effect. Something seems to be toggling the expand/collapse ability on and off inadvertently.

Attachments (1)

28581.patch (1.6 KB) - added by SergeyBiryukov 10 years ago.

Download all attachments as: .zip

Change History (8)

#1 @SergeyBiryukov
10 years ago

After adding console.log() to themes.view.Preview.collapse(), I've noticed that it runs multiple times in a row, and that number increases each time I click Next: 2, 6, 12, 20, 30, etc.

The same applies to other callbacks, probably because a new view is constructed each time you click Next or Previous. I'm not familiar enough with the code to fix it though.

#2 @SergeyBiryukov
10 years ago

_.once() doesn't fix this. Why do we use it for this.nextTheme(), but not for this.previousTheme()?

#3 @SergeyBiryukov
10 years ago

In 28777:

Fix copy/paste error in a comment.

see #28581.

#4 @SergeyBiryukov
10 years ago

  • Keywords has-patch added; needs-patch removed

28581.patch fixes both the uncontrollable duplication of callbacks and the collapsing issue for me.

I'm not entirely sure what 'click .preview': 'preview' is for (introduced in [27499]). The Preview button on Themes screen doesn't have that class, and the button on Add Themes screen doesn't require that line.

It contributes to the issue, causing themes.view.Theme.preview() to run twice on the same click, which in turn results in themes.view.Preview.collapse() running twice. Everything seems to work as expected without it.

this.undelegateEvents() prevents old callbacks from firing if you close the preview and reopen it. Otherwise themes.view.Preview.collapse() still runs multiple times.

Last edited 10 years ago by SergeyBiryukov (previous) (diff)

#5 @SergeyBiryukov
10 years ago

  • Keywords commit added

This ticket was mentioned in IRC in #wordpress-dev by SergeyBiryukov. View the logs.

10 years ago

#7 @SergeyBiryukov
10 years ago

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

In 28868:

Avoid duplication of callbacks in theme browser sidebar each time the Next or Previous button is clicked.

This makes the collapse/expand button work as expected.

fixes #28581.

Note: See TracTickets for help on using tickets.