Remove some modal subscriptions when inactive#73014
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. |
|
Size Change: -22 B (0%) Total Size: 2.45 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in 7999691. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/19106406944
|
scruffian
left a comment
There was a problem hiding this comment.
One question, but I think this is good to merge.
| const [ isModalOpen, setIsModalOpen ] = useState( | ||
| () => isNewPost && postType === 'wp_block' | ||
| const isNewPost = useSelect( | ||
| ( select ) => select( editorStore ).isCleanNewPost(), |
There was a problem hiding this comment.
Is it worth moving this to packages/edit-post/src/components/layout/index.js as well, so that this component has no subscriptions?
There was a problem hiding this comment.
No, it's actually better not to, as this component will only mount when you're editing a wp_block type, which is fairly rare. So, moving isCleanNewPost up would mean it would run more often, unnecessarily.
What?
Removes subscriptions from modals that are not active, and cannot be active in their given scenario.
Why?
Minor perf. Reduce subscriptions if easy and sensible.
How?
Modals don't need to be subscribed to changes when inactive. They only need the information when they are open. Don't subscribe to the store if the modal isn't active or won't be rendered in that context.
Testing Instructions
Generated by Claude AI
Test that the modal appears correctly:
Test that the modal doesn't mount unnecessarily:
Test the rename functionality:
Test the duplicate functionality:
Testing Instructions for Keyboard
Screenshots or screencast