Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiErrorBoundary] Use EuiCodeBlock to render error #5359

Merged
merged 4 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Fixed an `EuiDataGrid` race condition where grid rows had incorrect heights if loaded in before CSS ([#5284](https://github.com/elastic/eui/pull/5284))
- Fixed an accessibility issue where `EuiDataGrid` cells weren't owned by `role=row` elements ([#5285](https://github.com/elastic/eui/pull/5285))
- Wrapped content of `EuiErrorBoundary` with `EuiCodeBlock` which fixed the overflow scrolling ([#5359](https://github.com/elastic/eui/pull/5359))
cchaos marked this conversation as resolved.
Show resolved Hide resolved

## [`41.0.0`](https://github.com/elastic/eui/tree/v41.0.0)

Expand Down
10 changes: 0 additions & 10 deletions src/components/error_boundary/_error_boundary.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,5 @@
$color2 1px,
$color2 20px
);
overflow: auto;
padding: $euiSize;
}

.euiErrorBoundary__text {
background-color: $euiColorEmptyShade;
padding: $euiSizeS;
}

.euiErrorBoundary__stack {
white-space: pre-wrap;
}
17 changes: 8 additions & 9 deletions src/components/error_boundary/error_boundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import React, { Component, HTMLAttributes, ReactNode } from 'react';
import { CommonProps } from '../common';
import classNames from 'classnames';

import { EuiText } from '../text';
import { EuiTitle } from '../title';
import { EuiCodeBlock } from '../code';

interface EuiErrorBoundaryState {
hasError: boolean;
Expand Down Expand Up @@ -66,14 +67,12 @@ ${stackStr}`;
data-test-subj={dataTestSubj}
{...rest}
>
<div className="euiErrorBoundary__text">
<EuiText size="xs">
<h1>Error</h1>
<pre className="euiErrorBoundary__stack">
<p>{this.state.error}</p>
</pre>
</EuiText>
</div>
<EuiCodeBlock>
<EuiTitle size="xs">
<p>Error</p>
Copy link
Member

Choose a reason for hiding this comment

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

💯 I think changing this to a <p> makes more sense from an accessibility point of view- feel free to chime in if I'm missing something @1Copenut

Copy link
Contributor

Choose a reason for hiding this comment

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

@constancecchen I agree, paragraphs are more meaningful than divs here. It's permissible according to the spec, but this is a step up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For more context, this was actually an <h1> before. I'm not sure how our automated a11y tests didn't catch this page (it's not excluded). But I didn't think that top level heading was appropriate and usually just opt for paragraphs if we can't know for sure where this will lie in DOM hierarchy.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm guessing the page was either excluded or we're not doing best-practices checks. Either way, this works better and is semantically meaningful. I'll change my comment to approved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @1Copenut!

</EuiTitle>
{this.state.error}
</EuiCodeBlock>
</div>
);
}
Expand Down