-
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
Site Editor: Add error boundary #33921
Conversation
static getDerivedStateFromError( error ) { | ||
return { error }; | ||
} |
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 noticed that other ErrorBoundary
components use componentDidCatch
for fallback rendering while React documentation recommends using getDerivedStateFromError
.
Is there a special reason we want to use the componentDidCatch
lifecycle method?
Size Change: +318 B (0%) Total Size: 1.07 MB
ℹ️ View Unchanged
|
36b384d
to
e1795e4
Compare
It looks like adding an error boundary causes the "Performance Tests" to fail. |
It looks like moving the |
@@ -179,8 +180,6 @@ function Editor( { initialSettings } ) { | |||
return ( | |||
<> | |||
<URLQueryController /> | |||
<FullscreenMode isActive /> | |||
<UnsavedChangesWarning /> |
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.
Do you know if moving these two components has any impact?
Other than that, this is looking good.
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 tested, and I wasn't able to spot any.
The is-full-screen
class is applied to the body, and an "unsaved changes warning" is triggered if I try to reload the page.
Description
PR adds error boundary to the Site Editor. The fallback will render a warning message with actions to "Attempt Recovery" or "Copy Error." It's similar to other editor error boundaries.
Initially, I was planning to reuse the
ErrorBoundary
component from the editor package, but the "Copy Post Text" doesn't make sense in the context of site editing.I also moved the following components near the InterfaceSkeleton -
URLQueryController
,FullscreenMode
andUnsavedChangesWarning
.Fixes #33899.
How has this been tested?
Screenshots
Types of changes
Enhancement
Checklist:
*.native.js
files for terms that need renaming or removal).