-
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
Fix console warning by improving error handling in Nav block classic menu conversion #52591
Fix console warning by improving error handling in Nav block classic menu conversion #52591
Conversation
This is currently based on #52573. Will rebase once that one is merged. |
Size Change: +23 B (0%) Total Size: 1.43 MB
ℹ️ View Unchanged
|
58fb3de
to
70e93c2
Compare
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
Flaky tests detected in fb724d2. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5543404134
|
70e93c2
to
fb724d2
Compare
…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) ...
What?
Fixes console warning if classic menu import fails.
Discovered in #52573
Why?
By default the callback returned by the
useConvertClassicToBlockMenu
will throw an error if the import failed. This logs in console in the formIf we want to handle errors manually at call time then this is useful. However, the point of the hook is that it exposes the errors via status information and so in this case we wouldn't expect to need to handle the failure on the promise.
The code currently doesn't handle the promise and so we see a warning. We should fix that.
How?
Follows pattern established in Core Data whereby an options object allows consumers to switch returning of errors on/off.
Defaults to
false
meaning that the hook can be called without having to worry about the errors. But if you need the errors if can be switched on via the flag and then you cantry/catch
as required.Testing Instructions
This is tricky...
I added the following error here:
Then I tested the code we have now to validate that there are no
console
warnings when the import fails.Then I updated this line to pass the
throwOnError
option astrue
:gutenberg/packages/block-library/src/navigation/edit/index.js
Line 200 in 7d84f62
Then I re-tested and checked I could see the console warning about the uncaught promise.
Testing Instructions for Keyboard
Screenshots or screencast