Repository navigation
fix: guard against null closable in Panel - #594
Conversation
|
@mokshupadhyay is attempting to deploy a commit to the React Component Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. Walkthrough当 Changesnull closable 处理
Estimated code review effort: 2 (Simple) | ~5 minutes Change: Bug fix Suggested reviewers: Merge Risk:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #594 +/- ##
=======================================
Coverage 98.95% 98.95%
=======================================
Files 8 8
Lines 192 192
Branches 69 69
=======================================
Hits 190 190
Misses 2 2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
<Dialog closable={null} />throwsTypeError: Cannot read properties of null (reading 'disabled')while rendering, becausePaneldecides whether the close button is disabled withtypeof closable === 'object' && closable.disabled, andtypeof nullis'object'. Anullclosableis not in the declared type, but a plain-JS caller (or a value that comes from props, such asclosable={config?.closable ?? null}) can pass one, and the rest of the component already treats it likeundefined: no close button.The check is now
typeof closable === 'object' && closable !== null && closable.disabled, the samenullguard thatclosableObjalready uses ten lines above (typeof closable === 'object' && closable !== null), so the file now treatsnullthe same way in both places.Test:
should not crash and not display closeIcon when closable is nullfails onmasterwith theTypeErrorabove and passes now.npm test(6 suites, 61 passed, 1 skipped as before),npm run tscandnpm run lint(0 errors) pass.