WordPress.org

Make WordPress Core

Opened 4 weeks ago

Closed 13 days ago

Last modified 12 days ago

#48588 closed defect (bug) (fixed)

Unable to Replace Image in Image widget is using "Insert from URL"

Reported by: dufresnesteven Owned by: audrasjb
Milestone: 5.3.1 Priority: normal
Severity: normal Version: 5.3
Component: Widgets Keywords: has-patch fixed-major
Focuses: Cc:
PR Number:

Description

Version:
5.3-RC5-46725

Tested in:
Chrome (Version 78.0.3904.97 (Official Build) (64-bit))

Steps to Reproduce:

Notice that the window to replace the image does not open as expected.

Additional Information:

  • Works properly if the user has used an image from their Media Library
If the user does the same action on a mobile device, works properly -> Line in question -> (wp.media.isTouchDevice
e.url.focus())
  • Reproduced on a number of different themes


Console:

[media-widgets.min.js?m=1572623339h&ver=5.3-RC5-46725:1 Uncaught TypeError: e.url.focus is not a function

at i.embedContent (VM915 media-widgets.min.js:1)
at p (VM868 backbone.min.js:1)
at f (VM868 backbone.min.js:1)
at l (VM868 backbone.min.js:1)
at h.Collection.n.trigger (VM868 backbone.min.js:1)
at i.<computed> [as trigger] (VM843 media-views.min.js:1)
at i.trigger (VM843 media-views.min.js:1)
at i.render (VM843 media-views.min.js:1)
at i.mode (VM843 media-views.min.js:1)
at i.render (VM843 media-views.min.js:1)]

Attachments (1)

48588.diff (378 bytes) - added by afercia 3 weeks ago.

Download all attachments as: .zip

Change History (9)

#1 @SergeyBiryukov
4 weeks ago

  • Component changed from General to Widgets

#2 @audrasjb
4 weeks ago

  • Owner set to audrasjb
  • Status changed from new to reviewing
  • Version set to 5.3

Hi @dufresnesteven, Welcome to WordPress Trac and thank you for opening this ticket,

Self-assigning the ticket for review.

#3 @afercia
4 weeks ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to 5.3.1

I think this happens after [45499].

A possible fix would be changing view.url.focus() to view.url.input.focus().

However, it is preferable to not move focus in the first place, as that's an assumption on a user flow that may not be the intended one. See #43169.

I'd lean towards removing the code responsible for moving focus from src/js/_enqueues/wp/widgets/media.js.

@afercia
3 weeks ago

#4 @afercia
3 weeks ago

  • Keywords has-patch added; needs-patch removed

48588.diff avoids to move focus to the "Insert from URL" field, along the lines of the changes introduced in #43169 for the media views. By doing so, it avoids the reference to the backbone.js view.url which isn't the input field any longer after [45499].

#5 @afercia
3 weeks ago

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

In 46745:

Widgets: Avoid to move focus to the Image Widget "Insert from URL" field.

Fixes a bug after [45499], where the backbone view element isn't the input field any longer. Also, managing focus programmatically is often an assumption on a specific user flow and should generally be avoided, see #43169.

Props dufresnesteven.
See #43169.
Fixes #48588.

#6 @afercia
3 weeks ago

  • Keywords fixed-major added
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for 5.3.1 consideration.

#7 @SergeyBiryukov
13 days ago

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

In 46781:

Widgets: Avoid to move focus to the Image Widget "Insert from URL" field.

Fixes a bug after [45499], where the backbone view element isn't the input field any longer. Also, managing focus programmatically is often an assumption on a specific user flow and should generally be avoided, see #43169.

Props dufresnesteven, afercia.
Merges [46745] to the 5.3 branch.
See #43169.
Fixes #48588.

#8 @SergeyBiryukov
12 days ago

#48795 was marked as a duplicate.

Note: See TracTickets for help on using tickets.