Make WordPress Core

Opened 4 months ago

Last modified 4 days ago

#46964 accepted defect (bug)

ID attribute value are used multiple times in "Custom Field" form

Reported by: jankimoradiya Owned by: audrasjb
Milestone: 5.3 Priority: normal
Severity: normal Version: 5.0
Component: Editor Keywords: has-screenshots has-patch
Focuses: ui, accessibility Cc:


I have found that, ID attribute value like "poststuff" and "postbox-container-2" are used in multiple times in form of custom filed HTML.

Ex. id="poststuff" and id="postbox-container-2".

I thought that, It will need to update for better coding standard & improve acessibility.

Any suggestions are more welcomes...!!!

Attachments (2)

Screenshot.png (497.7 KB) - added by jankimoradiya 4 months ago.
46964.diff (10.6 KB) - added by donmhico 2 weeks ago.
Convert #poststuff and #postbox-container-2 to .poststuff and .postbox-container-2.

Download all attachments as: .zip

Change History (14)

#1 @SergeyBiryukov
4 months ago

  • Focuses performance removed

This ticket was mentioned in Slack in #accessibility by jankimoradiya. View the logs.

4 months ago

#3 @afercia
4 months ago

  • Component changed from Administration to Editor
  • Version changed from trunk to 5.0

This ticket was mentioned in Slack in #accessibility by afercia. View the logs.

4 months ago

#5 @afercia
4 months ago

  • Milestone changed from Awaiting Review to 5.3

Discussed during today's accessibility bug scrub and agreed to try this for the next 5.3 release.

#6 @desrosj
3 months ago

  • Focuses coding-standards removed

#7 @afercia
3 months ago

For reference for future contributors and history: WordPress does have HTML Coding Standards 😉


#8 @afercia
2 months ago

Seems to me this is related to what the_block_editor_meta_boxes() does. It loops through the meta boxes locations and then renders always the same IDs. I'm not sure these IDs are really necessary to start with, maybe they could be removed?

2 weeks ago

Convert #poststuff and #postbox-container-2 to .poststuff and .postbox-container-2.

#9 @donmhico
2 weeks ago

  • Keywords has-patch added; needs-patch removed

The main culprit for this, like @afercia mentioned, is the function the_block_editor_meta_boxes(). Specifically this block of code.

<?php foreach ( $locations as $location ) : ?>
    <form class="metabox-location-<?php echo esc_attr( $location ); ?>" onsubmit="return false;">
        <div id="poststuff" class="sidebar-open">
            <div id="postbox-container-2" class="postbox-container">
<?php endforeach; ?>

I think changing them to classes would be better than removing them. I also checked and only #postbox-container-2is inside a loop. The other ones #postbox-container-1, #postbox-container-3, and #postbox-container-4 are not.

This ticket was mentioned in Slack in #accessibility by audrasjb. View the logs.

4 days ago

#11 @audrasjb
4 days ago

  • Keywords needs-testing added
  • Owner set to audrasjb
  • Status changed from new to accepted

#12 @audrasjb
4 days ago

  • Keywords dev-feedback needs-testing removed

Hi @donmhico

I tested your patch and all looks good on my side.
There is still a duplicate ID on my test install, on a _wpnonce ID attribute. But that would be better to separate that in another patch so this one could land in 5.3.

Note: See TracTickets for help on using tickets.