-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Block Editor: Fix stale dependencies of selectors depending on editorTool preference #66833
Conversation
The `state.editorMode` reducer was removed in 65945 in favour of persisted user preferences. Selector `__unstableGetEditorMode` should be used instead. This commit fixes a bug wherein changes to `editorTool` don't trigger a re-render of the block list view. See: #65945
Size Change: +61 B (0%) Total Size: 1.82 MB
ℹ️ View Unchanged
|
Flaky tests detected in 2c9d260. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/11734772858
|
You are magic 🧙🏼 Works great for me, both when switching in the editor and in leaving/returning: write.mode.magic.mov |
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @xavier-lc. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't speak to the code but can speak to the outcome. Works great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had the same changes, thanks for the PR!
…be registry selectors
Pushed a commit to fix the failing tests. It looks like because |
@@ -116,7 +117,7 @@ export const getEnabledClientIdsTree = createSelector( | |||
state.blockEditingModes, | |||
state.settings.templateLock, | |||
state.blockListSettings, | |||
state.editorMode, | |||
__unstableGetEditorMode( state ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems wrong still, shouldn't it use select( store )
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed a commit, does that look better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like some tests need to be updated now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should now be fixed too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the fixes, @talldan! This was an end-of-day PR for me, and I didn't wait for the tests...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, thought I'd help out on the night shift, as it looked fairly urgent 😄
…Tool preference (#66833) * Block Editor: Fix dependencies of selectors depending on editorTool pref The `state.editorMode` reducer was removed in 65945 in favour of persisted user preferences. Selector `__unstableGetEditorMode` should be used instead. This commit fixes a bug wherein changes to `editorTool` don't trigger a re-render of the block list view. * Update selectors that use __unstableGetEditorMode as a dependency to be registry selectors * Update other selector * Fix tests --------- Co-authored-by: Daniel Richards <[email protected]>
Cherry-picked for 19.6.1. |
…Tool preference (WordPress#66833) * Block Editor: Fix dependencies of selectors depending on editorTool pref The `state.editorMode` reducer was removed in 65945 in favour of persisted user preferences. Selector `__unstableGetEditorMode` should be used instead. This commit fixes a bug wherein changes to `editorTool` don't trigger a re-render of the block list view. * Update selectors that use __unstableGetEditorMode as a dependency to be registry selectors * Update other selector * Fix tests --------- Co-authored-by: Daniel Richards <[email protected]>
Fixes #66463
What?
This fixes a bug wherein changes to the Write/Design mode selection don't trigger a re-render of the block list view.
How?
The
state.editorMode
reducer was removed in #65945 in favour of persisted user preferencecore.editorTool
. Selector__unstableGetEditorMode
should be used instead. This fix correctly adopts the latter as a dependency of selectorsgetEnabledClientIdsTree
andgetInsertBlockTypeDependants
.Testing Instructions
See parent issue. In short: in the site editor, keep the list view open, then switch between Write and Design modes, and confirm that the list view updates to show/hide certain blocks, such as template parts.