🐛 Fix Alert description wrapping (#20318)

close #20313
This commit is contained in:
偏右 2019-12-18 12:25:43 +08:00 committed by GitHub
parent 0195679fac
commit 4d6bcf4978
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View File

@ -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 <Alert type="error" message={errorMessage} description={errorDescription} />;
return (
<Alert type="error" message={errorMessage} description={<pre>{errorDescription}</pre>} />
);
}
return children;
}

View File

@ -13,10 +13,11 @@ exports[`Alert ErrorBoundary 1`] = `
<span
class="ant-alert-description"
>
in ThrowError
<pre>
in ThrowError
in ErrorBoundary (created by WrapperComponent)
in WrapperComponent
</pre>
</span>
</div>
`;

View File

@ -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;
}
}