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

Fixed EuiCodeBlock whitespace pre bug #3853

Merged
merged 8 commits into from
Aug 13, 2020
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## [`master`](https://github.com/elastic/eui/tree/master)

No public interface changes since `28.0.0`.
**Bug fixes**

- Fixed bug in `EuiCodeBlock` content overlapping with control buttons when `whiteSpace` was set to `"pre"` ([#3853](https://github.com/elastic/eui/pull/3853))

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

Expand Down
4 changes: 1 addition & 3 deletions src-docs/src/views/code/code_block_pre.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ export default () => (
whiteSpace="pre"
isCopyable>
{`export default () => (
<div>
In this example, the whiteSpace property is set to pre. All the whitespaces will be kept as is and the text only wraps when line breaks are in the content.
</div>
<div>In this example, the whiteSpace property is set to pre. All the whitespaces will be kept as is and the text only wraps when line breaks are in the content.</div>
);`}
</EuiCodeBlock>
</div>
Expand Down
26 changes: 23 additions & 3 deletions src/components/code/_code_block.scss
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@
// Storing for re-use the sizing of controls plus extra padding
$controlsPadding: $euiSizeL + $euiSizeXS;

&.euiCodeBlock--hasControls .euiCodeBlock__pre--whiteSpacePreWrap {
padding-right: $controlsPadding;
}

&.euiCodeBlock--hasControls .euiCodeBlock__pre--whiteSpacePre {
margin-right: $controlsPadding;
}

// Small padding
&.euiCodeBlock--paddingSmall {
.euiCodeBlock__pre {
Expand All @@ -81,9 +89,13 @@
right: $euiSizeS;
}

&.euiCodeBlock--hasControls .euiCodeBlock__pre {
&.euiCodeBlock--hasControls .euiCodeBlock__pre--whiteSpacePreWrap {
padding-right: $euiSizeS + $controlsPadding;
}

&.euiCodeBlock--hasControls .euiCodeBlock__pre--whiteSpacePre {
margin-right: $euiSizeS + $controlsPadding;
}
}

// Medium padding
Expand All @@ -97,9 +109,13 @@
right: $euiSize;
}

&.euiCodeBlock--hasControls .euiCodeBlock__pre {
&.euiCodeBlock--hasControls .euiCodeBlock__pre--whiteSpacePreWrap {
padding-right: $euiSize + $controlsPadding;
}

&.euiCodeBlock--hasControls .euiCodeBlock__pre--whiteSpacePre {
margin-right: $euiSize + $controlsPadding;
}
}

// Large padding
Expand All @@ -113,9 +129,13 @@
right: $euiSizeL;
}

&.euiCodeBlock--hasControls .euiCodeBlock__pre {
&.euiCodeBlock--hasControls .euiCodeBlock__pre--whiteSpacePreWrap {
padding-right: $euiSizeL + $controlsPadding;
}

&.euiCodeBlock--hasControls .euiCodeBlock__pre--whiteSpacePre {
margin-right: $euiSizeL + $controlsPadding;
}
}

/*
Expand Down