Make WordPress Core

Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#40589 closed defect (bug) (fixed)

Media: Replace button enabled when no media item selected

Reported by: timmydcrawford Owned by: adamsilverstein
Priority: normal Milestone: 4.9
Component: Media Version:
Severity: normal Keywords: has-patch has-screenshots commit
Cc: Focuses: javascript

Description

Initially discovered while working on the new Media Widgets for the customizer:
​https://github.com/xwp/wp-core-media-widgets/issues/102

Steps to Recreate:

  • Open up a post in the editor
  • Insert an image via the "Add Media" button
  • Once the image is displayed in the editor, click the pencil icon to open the image editor modal
  • Click the "Replace" button below the image
  • Note the current image is selected in the replace view, and the "Replace" button is enabled
  • Un-select the current image so no image is selected, note the "Replace" button is still enabled
  • Click the "Replace" button, and an error will be thrown ( see screenshot )

Some logic could be added to prevent the exception, but ideally it seems like the "Replace" button should be disabled when there is no active selection.

Attachments (4)

replace-button-error.png​ (61.5 KB ) - added by timmydcrawford 10 years ago.
Screencast 2017-04-28 15:11:27.mp4​ (4.9 MB ) - added by subrataemfluence 10 years ago.
Screen cast of step by step operation
40589.diff​ (1.4 KB ) - added by psiico 10 years ago.
patch
40589.2.diff​ (429 bytes ) - added by adamsilverstein 10 years ago.

Change History (15)

#1 @subrataemfluence
10 years ago

Please disregard added screen cast. I missed the "trunk". Sorry for this.

#2 @psiico
10 years ago

  • Keywords has-patch needs-testing added

#3 @psiico
10 years ago

  • Keywords has-screenshots added

https://www.dropbox.com/s/7h6vcaras80r3uw/40589.gif

#4 @adamsilverstein
10 years ago

@psiico

Thanks for your work and patch here, and for providing the screencast.

We don't need to track selection in the click callback because the toolbar component already supports a section: required attribute that produces the desired behavior.

40589.2.diff​ is an alternate approach that uses that feature.

Can you please test? Thanks.

This ticket was mentioned in ​Slack in #core by timmyc. ​View the logs.


10 years ago

#6 @timmydcrawford
10 years ago

40589.2.diff​ is testing out well for me - the button is disabled now until an item is selected.

#7 @ocean90
9 years ago

  • Milestone Awaiting Review → Future Release
  • Version trunk

#8 @adamsilverstein
9 years ago

  • Keywords commit added; needs-testing removed

#9 @adamsilverstein
9 years ago

  • Owner set to adamsilverstein
  • Resolution → fixed
  • Status new → closed

In 40902:

Media: Disable the edit image->replace button when no item selected.

On the edit media screen, ensure that the 'replace' button is disabled until a media item is selected. Fix an issue where clicking the button with no item selected threw a JavaScript error and failed to work.

Props timmydcrawford, subrataemfluence, psiico.
Fixes #40589.

#10 @netweb
9 years ago

  • Milestone Future Release → 4.9

#11 @wonderboymusic
9 years ago

#36453 was marked as a duplicate.

Note: See TracTickets for help on using tickets.