[wp-trac] [WordPress Trac] #48236: Media attachment browser no longer provides id of attachment
WordPress Trac
noreply at wordpress.org
Thu Feb 13 16:30:17 UTC 2020
#48236: Media attachment browser no longer provides id of attachment
-------------------------------------+-----------------------------
Reporter: slebog | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 5.4
Component: Media | Version: 5.2.3
Severity: normal | Resolution:
Keywords: has-patch needs-refresh | Focuses: administration
-------------------------------------+-----------------------------
Changes (by afercia):
* keywords: has-patch needs-testing => has-patch needs-refresh
Comment:
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.
[attachment:"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)
--
Ticket URL: <https://core.trac.wordpress.org/ticket/48236#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list