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

Block Styles: Fix long strings of text without spaces overflow the block #34222

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion packages/block-library/src/button/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $blocks-block__margin: 0.5em;
padding: calc(0.667em + 2px) calc(1.333em + 2px); // The extra 2px are added to size solids the same as the outline versions.
text-align: center;
text-decoration: none;
overflow-wrap: break-word;
word-break: break-word; // overflow-wrap doesn't work well if a link is wrapped in the div, so use word-break here.
Copy link
Contributor

Choose a reason for hiding this comment

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

I tested that buttons needs word-break in order to wrap correctly wheras headings will wrap with overflow-wrap alone (Tested in Chrome). 👍

But I couldn't work out why this is the case. I think that the comment is good for this interesting case. 👍

box-sizing: border-box;

&:hover,
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/embed/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

.wp-block-embed {
margin: 0 0 1em 0;
overflow-wrap: break-word; // Break long strings of text without spaces so they don't overflow the block.

// Supply caption styles to embeds, even if the theme hasn't opted in.
// Reason being: the new markup, figcaptions, are not likely to be styled in the majority of existing themes,
Expand Down
3 changes: 3 additions & 0 deletions packages/block-library/src/heading/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ h3,
h4,
h5,
h6 {
// Break long strings of text without spaces so they don't overflow the block.
overflow-wrap: break-word;

&.has-background {
padding: $block-bg-padding--v $block-bg-padding--h;
}
Expand Down
11 changes: 8 additions & 3 deletions packages/block-library/src/list/style.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
ol.has-background,
ul.has-background {
padding: $block-bg-padding--v $block-bg-padding--h;
ol,
ul {
// Break long strings of text without spaces so they don't overflow the block.
overflow-wrap: break-word;

&.has-background {
padding: $block-bg-padding--v $block-bg-padding--h;
}
}
5 changes: 5 additions & 0 deletions packages/block-library/src/paragraph/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
font-style: normal;
}

p {
// Break long strings of text without spaces so they don't overflow the block.
overflow-wrap: break-word;
}

// Prevent the dropcap from breaking out of the box when a background is applied.
p.has-drop-cap.has-background {
overflow: hidden;
Expand Down
1 change: 1 addition & 0 deletions packages/block-library/src/pullquote/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
margin: 0 0 1em 0;
padding: 3em 0;
text-align: center; // Default text-alignment where the `textAlign` attribute value isn't specified.
overflow-wrap: break-word; // Break long strings of text without spaces so they don't overflow the block.

p,
blockquote,
Expand Down
2 changes: 2 additions & 0 deletions packages/block-library/src/quote/style.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.wp-block-quote {
overflow-wrap: break-word; // Break long strings of text without spaces so they don't overflow the block.

&.is-style-large,
&.is-large {
margin-bottom: 1em;
Expand Down