From 4d6bcf4978b56d38e6d7ef8716151d1670753696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=81=8F=E5=8F=B3?= Date: Wed, 18 Dec 2019 12:25:43 +0800 Subject: [PATCH] :bug: Fix Alert description wrapping (#20318) close #20313 --- components/alert/ErrorBoundary.tsx | 4 +++- components/alert/__tests__/__snapshots__/index.test.js.snap | 5 +++-- components/alert/style/index.less | 5 +++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/components/alert/ErrorBoundary.tsx b/components/alert/ErrorBoundary.tsx index 668ef94156..abf55b2816 100644 --- a/components/alert/ErrorBoundary.tsx +++ b/components/alert/ErrorBoundary.tsx @@ -34,7 +34,9 @@ export default class ErrorBoundary extends React.Component< const errorDescription = typeof description === 'undefined' ? componentStack : description; if (error) { // You can render any custom fallback UI - return ; + return ( + {errorDescription}} /> + ); } return children; } diff --git a/components/alert/__tests__/__snapshots__/index.test.js.snap b/components/alert/__tests__/__snapshots__/index.test.js.snap index 9bd196a537..81d743625e 100644 --- a/components/alert/__tests__/__snapshots__/index.test.js.snap +++ b/components/alert/__tests__/__snapshots__/index.test.js.snap @@ -13,10 +13,11 @@ exports[`Alert ErrorBoundary 1`] = ` - - in ThrowError +
+          in ThrowError
     in ErrorBoundary (created by WrapperComponent)
     in WrapperComponent
+    
`; diff --git a/components/alert/style/index.less b/components/alert/style/index.less index 0d9e392815..cf3bd24d2a 100644 --- a/components/alert/style/index.less +++ b/components/alert/style/index.less @@ -68,8 +68,9 @@ color: @alert-error-icon-color; } - .@{alert-prefix-cls}-description { - white-space: pre; + .@{alert-prefix-cls}-description > pre { + margin: 0; + padding: 0; } }