Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#34716 closed defect (bug) (fixed)

Using wplink (wp_editor) on front end is triggering a js error due to unsatisfied dependency

Reported by: imath Owned by: azaozz
Milestone: 4.4 Priority: normal
Severity: normal Version: 4.3
Component: Editor Keywords: needs-patch
Focuses: accessibility, javascript Cc:


wplink should include jquery-ui-core in its dependencies as it uses it > $.ui

When using the wp_editor in front end, if you click on the link button, and once the window is opened, if you try to type some text for the link's text, you get :
Uncaught TypeError: Cannot read property 'keyCode' of undefined

I think that's because $.ui is not defined, because the jquery-ui-core is not enqueued on front-end (it's enqueued in the post edit Administration screen).

Using the attached patch is fixing the issue for me.

Attachments (2)

34716.patch (682 bytes) - added by imath 5 years ago.
34716.2.patch (1.5 KB) - added by afercia 5 years ago.

Download all attachments as: .zip

Change History (9)

5 years ago

#1 @swissspidy
5 years ago

  • Keywords has-patch added

#2 follow-up: @DrewAPicture
5 years ago

  • Owner set to azaozz
  • Status changed from new to reviewing
  • Version trunk deleted

@azaozz Mind taking a look? Based on snooping around in blame, this might've been around for a while now.

#3 @afercia
5 years ago

  • Focuses accessibility added

Be sure to be logged out to reproduce the bug. Also, this impacts accessibility since tabbing is no more constrained inside the link modal etc.

5 years ago

#4 @afercia
5 years ago

  • Version set to 4.3

Looking back at this, wondering why jQuery UI is used in the first place. Maybe some historical need for key codes normalization but as today I think event.keyCode is safe to use?
See attached patch, getting rid of $.ui so there's no need to set jquery-ui-core as dependency.
Any thoughts?

#5 in reply to: ↑ 2 @azaozz
5 years ago

  • Milestone changed from Awaiting Review to 4.4

Replying to DrewAPicture:
Replying to afercia:

Long time ago wplink was using UI dialog. Seems $.ui.keyCode was never removed after converting it to "plain" JS.

Thinking the better way to fix this is to stop using $.ui.keyCode as in 34716.2.patch. There is a (very) small chance of version collision if we enqueue jquery-ui-core on the front.

Last edited 5 years ago by azaozz (previous) (diff)

#6 @DrewAPicture
5 years ago

  • Keywords needs-patch added; has-patch removed

#7 @azaozz
5 years ago

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

In 35728:

Editor: remove wpLink dependency on jQuery UI.

Props afercia.
Fixes #34716.

Note: See TracTickets for help on using tickets.