#40589 closed defect (bug) (fixed)
Media: Replace button enabled when no media item selected
Reported by: | timmydcrawford | Owned by: | adamsilverstein |
---|---|---|---|
Milestone: | 4.9 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Media | Keywords: | has-patch has-screenshots commit |
Focuses: | javascript | Cc: |
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)
Change History (15)
#4
@
7 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.
7 years ago
#6
@
7 years ago
40589.2.diff is testing out well for me - the button is disabled now until an item is selected.
Screen cast of step by step operation