close
Skip to content

Media: Remove required attribute from media uploader file input field#10564

Closed
t-hamano wants to merge 1 commit intoWordPress:trunkfrom
t-hamano:64305-remove-required-attr
Closed

Media: Remove required attribute from media uploader file input field#10564
t-hamano wants to merge 1 commit intoWordPress:trunkfrom
t-hamano:64305-remove-required-attr

Conversation

@t-hamano
Copy link
Copy Markdown
Contributor

@t-hamano t-hamano commented Nov 28, 2025


Summary

When the media upload form operates as a normal async uploader, the file input element with the required attribute is visually hidden. When a form submit is performed on a form element with this attribute, the following error is displayed in the browser console, and the form is not submitted:

An invalid form control with name='async-upload' is not focusable.

This issue affects all implementations that run the media_upload_form() function within a form element.

As a temporary workaround for 6.9, remove the required attribute from the file input element.

Testing Instructions

✅ or ⚠️ indicates that this PR will change the results.

Default Media Uploader

  • Access http://localhost:8889/wp-admin/media-new.php
  • Click the "browser uploader" link
  • If JS is enabled: The Upload button should be disabled unless a file is attached.
  • ⚠️ If JS is disabled: The form will be submitted without attaching a file, but validation will be performed on the server side, and the message "No file was uploaded." will be displayed. Since cases where JS is disabled are rare these days, I think this case is acceptable.

Legacy Media Uploader

  • Access http://localhost:8889/wp-admin/media-upload.php
  • Click the "browser uploader" link
  • ⚠️ The form will be submitted without attaching a file, but validation will be performed on the server side, and the message "No file was uploaded." will be displayed. Since the legacy uploader will probably be used very little anymore, I think this case is acceptable.

Backward compatibility with third-party plugins

@github-actions
Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@t-hamano t-hamano marked this pull request as ready for review November 28, 2025 07:19
@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 28, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props wildworks, krupajnanda, yagniksangani.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@kjnanda
Copy link
Copy Markdown

kjnanda commented Nov 28, 2025

@t-hamano I have tested this PR and verified all these scenarios mentioned here.

  • Default Media Uploader ✅
  • Legacy Media Uploader ✅
  • Backward compatibility with third-party plugin. Eg. Envira gallery ✅
  • Also, did a quick round of regression testing for different scenarios like drag-and-drop images, image short-code, multi file upload functionality etc just to ensure everything else is working as expected. ✅

Please confirm if there is anything I have missed. 🙇🏻‍♀️

@yagniksangani
Copy link
Copy Markdown

@t-hamano, Thanks for the fix. I have tested this PR and verified all the mentioned scenarios.

✅ Default Media Uploader
✅ Legacy Media Uploader
✅ Backward compatibility with third-party (Checked with Envira gallery and Soliloquy Slider Plugins)

Just to confirm, will this issue fix be included in the WordPress 6.9 release?

Copy link
Copy Markdown
Member

@adamsilverstein adamsilverstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@github-actions
Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 61320
GitHub commit: 3423501

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Nov 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants