-
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] Add optional chaining to reusableBlock.title
#53721
[RNMobile] Add optional chaining to reusableBlock.title
#53721
Conversation
This commit adds safety checks for the `title` property within `reusableBlock`. By using optional chaining, the code now gracefully handles scenarios where `title` might be undefined, preventing a TypeError from being thrown.
Size Change: 0 B Total Size: 1.51 MB ℹ️ View Unchanged
|
Flaky tests detected in abb51ba. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5876946940
|
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!
Adding this optional chaining makes sense to me, as you mentioned there are other places with the same approach 👍.
It's hard when we have these kinds of crashes that are hard to reproduce, let's merge and see how it goes. 🚀
The test cases work as expected for synced patterns with both titles and no titles.
This PR adds safety checks for the `title` property within `reusableBlock`. By using optional chaining, the code now gracefully handles scenarios where `title` might be undefined, preventing a TypeError from being thrown.
* Release script: Update react-native-editor version to 1.101.0 * Release script: Update with changes from 'npm run core preios' * Update `react-native-editor` CHANGELOG * Remove incorrect CHANGELOG entry The iOS focus loop will be included in 1.100.2. I've updated the CHANGELOG accordingly. * Release script: Update react-native-editor version to 1.101.1 * Release script: Update with changes from '$PRE_IOS_COMMAND' * fix: Dynamic bottom sheet height (#53608) Stretching this content with flex appears to be necessary after upgrading React Native or refactoring the bottom sheet height animation. Refactor: 0411df1 Upgrade: c2957aa * fix: Optional chaining to handle undefined title (#53721) This PR adds safety checks for the `title` property within `reusableBlock`. By using optional chaining, the code now gracefully handles scenarios where `title` might be undefined, preventing a TypeError from being thrown. * Update CHANGELOG * Release script: Update react-native-editor version to 1.101.2 * Release script: Update with changes from 'npm run core preios' * [Mobile] - Fix Voice Over and assistive keyboards (#53895) * AztecView - Replace usage of TouchableWithoutFeedback with Pressable - This fixes the current React Native regression with VoiceOver and assistive keyboards * Patch React Native's TextInput component to avoid passing the recently introduced accessibilityState prop which causes issues with assistive keyboards * Updates snapshots: Fule, Audio blocks and Search component after changing the AztecView component to use Pressable * Update AztecView's Pressable with changing its accessible prop to false * Update Changelog --------- Co-authored-by: Siobhan <siobhan@automattic.com> Co-authored-by: David Calhoun <github@davidcalhoun.me> Co-authored-by: Gerardo <gerardo.pacheco@automattic.com>
Potential fix for wordpress-mobile/gutenberg-mobile#5496 and wordpress-mobile/WordPress-iOS#21083
What?
This PR adds optional chaining to
reusableBlock.title
within thebuildReusableBlockInserterItem
function:gutenberg/packages/block-editor/src/store/selectors.js
Line 1981 in abb51ba
Why?
We've received multiple reports of Gutenberg Mobile crashing with the following error:
The change in this PR is an attempt to fix that crash.
How?
Even after digging deeply into user reports and available logs, attempts to reproduce the crash have been unsuccessful. The main clue we have to go on is that
n.title.raw
in the app's generated bundle points to the instance of reusable blocks returned by the inserter.From the checks in place within
getReusableBlocks
, we can reasonably infer thatreusableBlocks
wouldn't be undefined. As such, this PR adds optional chaining to thetitle
property withinreusableBlock
.(Note, the same pattern can be found within the
__experimentalGetReusableBlockTitle
function in the same file.)By using optional chaining, the code now gracefully handles scenarios where
title
might be undefined, which should prevent the TypeError from being thrown.Testing Instructions
As the crash isn't easily reproducible, there isn't a straight forward way to ensure this PR fixes it. Instead, the logic of making these change should be verified.
In both the app and on the web, we should also ensure that there are no regressions related to reusable blocks/synced patterns with no titles: