Opened 5 years ago
Last modified 5 years ago
#48236 new defect (bug)
Media attachment browser no longer provides id of attachment
Reported by: | slebog | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 5.2.3 |
Component: | Media | Keywords: | has-patch needs-refresh |
Focuses: | administration | Cc: |
Description
This is a follow-up to #47458.
Issue #47458 removed the data-id attribute from the media attachment browser. This was a useful attribute, used by an (internal) plugin on our site to access the details of the currently displayed attachment. We used code similar to this to hook into the dialog:
wp.media.view.Attachment.Details.prototype.on('ready', function() { var postid = $('.attachment-details').data('id'), details = wp.media.attachment(postid); // do stuff with details });
This functionality is now broken, and I can’t see another way to access the id of the attachment details being shown. (The item id in the query string is not reliable, as it’s not always updated in time, or at all.)
Could this useful attribute be restored? It doesn’t seem to affect the problem addressed in #47458 in any way.
Attachments (1)
Change History (13)
This ticket was mentioned in Slack in #core by marybaum. View the logs.
5 years ago
#6
@
5 years ago
- Keywords needs-testing added
- Milestone changed from 5.2.5 to 5.4
Unfortunately, with the impending 5.3 RC1, time has run out for this one.
I am going to punt to 5.4 for now, but it can be moved up into a minor when ready.
This ticket was mentioned in Slack in #accessibility by audrasjb. View the logs.
5 years ago
#8
@
5 years ago
- Focuses accessibility removed
Hi,
As per today's accessibility team bug scrub, it doesn't appear to be really related to accessibility focus.
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
5 years ago
#10
@
5 years ago
- Keywords needs-refresh added; needs-testing removed
Some history: The attachment details inherits from Attachment
, which is a <li>
element with several attributes:
attributes: function() { return { 'tabIndex': 0, 'role': 'checkbox', 'aria-label': this.model.get( 'title' ), 'aria-checked': false, 'data-id': this.model.get( 'id' ) }; },
Before [30483] / #30390 Attachment.Details inherited all those attributes, which was incorrect for this <div>
element used in the media modal. The incorrect output was something like this:
<div tabindex="0" role="checkbox" aria-label="{ alt or file name }" aria-checked="false" data-id="6460" class="attachment-details save-ready" >
[30483] reset most of them keeping just tabIndex
and data-id
.
Then, [45506] / #47458 removed all the attributes by using an empty object attributes: {}
. The tabindex
attribute was producing an unexpected tab stop on an unlabeled element. The data-id
attribute was not used by core nor was documented anywhere or part of an official API, at least to my knowledge.
It it's something plugins are largely using, then it's certainly possible to consider to restore it. The important part is to avoid inheritance from Attachment
otherwise this element will get again all the previous incorrect, unnecessary, HTML attributes.
48236.diff looks good to me except for:
- there should be just one space before
this.model.get( 'id' )
- the comment should be updated accordingly, and explain why we're explicitly setting an attribute that's already inherited (we'd do this to reset the other attributes)
This ticket was mentioned in Slack in #core-media by antpb. View the logs.
5 years ago
#12
@
5 years ago
- Milestone changed from 5.4 to Future Release
Hi,
With 5.4 Beta 3 approaching and the Beta period reserved for bugs introduced during the cycle, this is being moved to Future Release. If any maintainer or committer feels this should be included or wishes to assume ownership during a specific cycle, feel free to update the milestone accordingly.
Moving to the 5.2.4 milestone as this was introduced in a point release so ought to be back ported for sites affected by the auto update.