[wp-trac] [WordPress Trac] #52638: JS error when clicking a submenu heading on the collapsed admin menu

WordPress Trac noreply at wordpress.org
Wed Feb 24 11:43:42 UTC 2021


#52638: JS error when clicking a submenu heading on the collapsed admin menu
----------------------------+--------------------
 Reporter:  SergeyBiryukov  |      Owner:  (none)
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  5.7
Component:  Administration  |    Version:
 Severity:  normal          |   Keywords:
  Focuses:  ui              |
----------------------------+--------------------
 Reported by @peterwilsoncc in comment:82:ticket:51812:
 > Overnight I twigged to another regression in [50420] -- in a few places
 `$thing.get(0).trigger()` is used. These will need to be changed to
 `$thing.eq(0).trigger()` as jQuery's `get()` function returns a DOM
 element rather than a jQuery object.

 I've found a single instance of this in `js/_enqueues/admin/common.js`:

 1. Click the "Collapse menu" button at the bottom of the admin menu.
 2. Hover any icon and click the submenu heading (with the `.wp-submenu-
 head` class), e.g. "Posts".
 3. You'll get an error in the console:
 {{{
 Uncaught TypeError: $(...).parent(...).siblings(...).get(...).trigger is
 not a function
     at HTMLLIElement.<anonymous>
 (common.js?ver=5.8-alpha-20210224.134900:843)
     at HTMLUListElement.dispatch (jquery.js?ver=3.5.1:5429)
     at HTMLUListElement.elemData.handle (jquery.js?ver=3.5.1:5233)
 }}}

 Same as in [50383], the `click()` method there is not the jQuery method,
 but is an [https://developer.mozilla.org/en-
 US/docs/Web/API/HTMLElement/click HTML DOM method instead], so the change
 to that line can be reverted.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/52638>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list