Skip to content

Conversation

@pan-kot
Copy link
Member

@pan-kot pan-kot commented Aug 8, 2025

Description

See: [3akTAfFaeBUk]

How has this been tested?

  • Unit tests and test pages for manual testing
Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@pan-kot pan-kot force-pushed the error-boundaries branch 2 times, most recently from 2826547 to 84097f7 Compare August 8, 2025 13:13
@pan-kot pan-kot changed the title poc chore: Error boundaries POC Aug 8, 2025
@pan-kot pan-kot force-pushed the error-boundaries branch 3 times, most recently from b52bd30 to df1bd58 Compare August 14, 2025 09:50
@pan-kot pan-kot force-pushed the error-boundaries branch 3 times, most recently from 1f1f616 to 762147a Compare September 24, 2025 10:27
@pan-kot pan-kot force-pushed the error-boundaries branch 8 times, most recently from 9c9b0ef to bc8b8de Compare November 13, 2025 13:15
@pan-kot pan-kot force-pushed the error-boundaries branch 2 times, most recently from 6e677ac to 1b6cea2 Compare November 14, 2025 09:07
</div>
{activeDrawerId !== TOOLS_DRAWER_ID && (
<div className={styles['drawer-content']} style={{ blockSize: drawerHeight }}>
<div key={activeDrawerId} className={styles['drawer-content']} style={{ blockSize: drawerHeight }}>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing React key forces component re-mount when new drawer is rendered. This clears the Drawer's internal state including the error state of the built-in error boundary. Without this, if an error boundary is triggered in one drawer - it will be shown in all drawers.

@codecov
Copy link

codecov bot commented Nov 14, 2025

Codecov Report

❌ Patch coverage is 96.72131% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.12%. Comparing base (6b10cd4) to head (7b6a0f7).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/container/internal.tsx 83.33% 2 Missing ⚠️
src/error-boundary/internal.tsx 97.36% 1 Missing ⚠️
src/modal/internal.tsx 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3736      +/-   ##
==========================================
- Coverage   97.13%   97.12%   -0.01%     
==========================================
  Files         866      870       +4     
  Lines       25399    25488      +89     
  Branches     9183     9215      +32     
==========================================
+ Hits        24671    24756      +85     
+ Misses        722      685      -37     
- Partials        6       47      +41     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

[styles['header-with-media']]: hasMedia,
[styles['header-full-page']]: __fullPage && isRefresh,
}
<BuiltInErrorBoundary wrapper={content => <InternalBox padding="m">{content}</InternalBox>}>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The container paddings are implemented separately in its header, body, and footer. When we replace all these slots with the error boundary fallback, these paddings are lost - that's why we wrap the fallback in a padded box.

>
<BuiltInErrorBoundary
wrapper={content => (
<InternalBox padding={disableContentPaddings ? 'm' : undefined}>{content}</InternalBox>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When disableContentPaddings is used, the container has no internal paddings around content, expecting the paddings to come from the content. However, the internal content paddings are lost in case there is an error in the content - that's why we add them back with a padded box around the fallback message.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for these nice explanations. Why not incorporate them as code comments (maybe in a slightly more succinct form)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point - I will add the code comments 👍

}

componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void {
this.props.onError({ error, errorInfo, errorBoundaryId: this.props.errorBoundaryId });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change breaks the unit tests below, which assert we are permissive and don't crash if not providing the onError prop (even if it is required)

jperals
jperals previously approved these changes Dec 9, 2025
@pan-kot pan-kot added this pull request to the merge queue Dec 18, 2025
Merged via the queue into main with commit 94344c6 Dec 18, 2025
49 checks passed
@pan-kot pan-kot deleted the error-boundaries branch December 18, 2025 12:36
gethinwebster added a commit that referenced this pull request Dec 22, 2025
pan-kot added a commit that referenced this pull request Dec 29, 2025
georgylobko pushed a commit that referenced this pull request Dec 30, 2025
ngynmt pushed a commit to ngynmt/components that referenced this pull request Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants