Skip to content

Commit

Permalink
🐛 Fix Alert descriptin wrapping
Browse files Browse the repository at this point in the history
close #20313
  • Loading branch information
afc163 committed Dec 18, 2019
1 parent 0195679 commit 45dd1e5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion components/alert/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 3 additions & 2 deletions components/alert/__tests__/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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>
`;
5 changes: 3 additions & 2 deletions components/alert/style/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit 45dd1e5

Please sign in to comment.