-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[RNMobile] Fix crash related to removing a block under certain conditions #52595
Conversation
When determining if the block is groupable/ungroupable, we now avoid passing an undefined value which leads to a crash.
Size Change: 0 B Total Size: 1.43 MB ℹ️ View Unchanged
|
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.
LGTM! 🚀 The web editor also has some checks around this in:
gutenberg/packages/block-editor/src/components/block-settings-menu-controls/index.js
Line 40 in 033c5e3
clientIds !== null ? clientIds : getSelectedBlockClientIds(); |
Where it checks a value for clientIds
that is not null
. I checked that useConvertToGroupButtonProps
works fine with either passing null
or an empty array.
So it makes sense we do the same to avoid these crashes.
…#52595) When determining if the block is groupable/ungroupable, we now avoid passing an undefined value which leads to a crash.
…dd/defer-script-loading-strategy * 'trunk' of https://github.com/WordPress/gutenberg: (24 commits) Add filter to turn off Interactivity API for a block (#52579) Search: Remove unnecessary useEffect (#52604) Navigation: Simplify the useSelect for useNavigationMenus (#51977) Item: Unify focus style and add default font styles (#52495) Update Changelog for 16.2.1 Bump plugin version to 16.2.1 Avoid passing undefined `selectedBlockClientId` in `BlockActionsMenu` (#52595) Cover Block: Fix block deprecation when fixed background is enabled (#51612) Nav block: link text color inheritance fixes and tests (#51710) Stabilize defaultBlock, directInsert API's and getDirectInsertBlock selector (#52083) Fix console warning by improving error handling in Nav block classic menu conversion (#52591) Fix: Remove link action of Link UI for draft pages created from Nav block does not correctly remove link. (#52415) Lodash: Remove remaining `_.get()` from block editor and deprecate (#52561) Fix importing classic menus (#52573) ResizableFrame: Make keyboard accessible (#52443) Site Editor: Fix navigation menu sidebar actions order and label (#52592) correct a typo: sapce -> space (#52578) Avoid errors in Dimension visualizers when switching between iframed and non-iframed editors (#52588) Patterns: Add client side pagination to patterns list (#52538) Site Editor: Make sidebar back button go *back* instead of *up* if possible (#52456) ...
* Release script: Update react-native-editor version to 1.99.0 * Release script: Update with changes from 'npm run core preios' * Update `react-native-editor` changelog * Release script: Update react-native-editor version to 1.99.1 * Release script: Update with changes from 'npm run core preios' * Avoid passing undefined `selectedBlockClientId` in `BlockActionsMenu` (#52595) When determining if the block is groupable/ungroupable, we now avoid passing an undefined value which leads to a crash. * Update `react-native-editor` changelog
What?
Fixes a crash produced when removing a block under certain conditions. The crash was originally identified when removing a File block in a post/page with only that block. However, it has also been able to reproduce when detaching a synced pattern in a post with other blocks.
Why?
Fixes the crash wordpress-mobile/gutenberg-mobile#5925.
How?
When determining if the block is groupable/ungroupable, we now avoid passing an
undefined
value which leads to a crash. We now check ifselectedBlockClientId
is defined, and based on that it passes an empty array when callinguseConvertToGroupButtonProps
.I was curious about why this only happens in specific blocks and noticed the following:
BlockActionsMenu
component can be re-rendered after the block is removed but before the default Paragraph block is inserted.Removing File block:
BlockActionsMenu
component is only re-rendered after the default block is inserted.Removing Image block:
For some reason, on specific blocks, the Redux state updates after removing the block are causing a re-render in
BlockActionsMenu
component. I checked the parameters of both Redux actionsREMOVE_BLOCKS
andEDIT_ENTITY_RECORD
(this one is triggered by the block removal), but there's no specific value that differs from removing other blocks 🤔.Testing Instructions
Testing Instructions for Keyboard
N/A
Screenshots or screencast
Simulator.Screen.Recording.-.iPhone.14.-.2023-07-13.at.13.32.01.mp4
Simulator.Screen.Recording.-.iPhone.14.-.2023-07-13.at.13.31.24.mp4