Repository navigation
Conversation
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @aadil42! In case you missed it, we'd love to have you join us in our Slack community. If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information. |
|
Thanks, @aadil42! Looking at the file history, it seems that the use of a class component is intentional (#73225). cc @tellthemachines |
|
@Mamaduka, Sorry for the late reply. Yeah looking at the file history the class component is intentional here. Some plugins (AMP plugin) are using MediaUpload thinking it to be a class component. But the last change to the file added deprecated warning
So my guess is that after 7.2 version we should refactor it to be a class component. Should we keep this PR open then so we can merge it later? |
|
It will need further testing. I doubt this will be removed in the recent release. Let's close this PR so we don't merge refactoring sooner than needed and break consumer code. Thanks again, @aadil42! |

What?
Refactors
MediaUploadModalWrapperinpackages/editor/src/hooks/media-upload.jsfrom a class component to a function component, part of the ongoing class → function migration #22890.Why?
Refactors as part of the broader class → component migration tracked in #22890.
How?
isOpen) fromthis.statetouseStateopenModal,closeModal) in favor of plain functionsrender()becomes a direct return, no lifecycle methods needed since there were none to begin withallowedTypes,multiple,value,onSelect,title,modalClass,render,onClose) is unchangedTesting Instructions
The component previously had no tests. This PR adds coverage for the render-prop trigger, opening the modal, selecting media (calls onSelect and closes), and closing without selecting (calls onClose).
you can run unit test as shown below:
Testing Instructions for Keyboard
Use of AI Tools
Assisted by Claude.