Skip to content

Fix horizontal scrollbars on Safari when code blocks are very long #700

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

Conversation

dobromir-hristov
Copy link
Contributor

Bug/issue #, if applicable: 110741983

Summary

Fixes a bug on Safari, where if the last line in a codeblock is very long, the after accessibility pseudo element helper gets pushed to the side, causing the browser to render hirozontal scrollbars.

Dependencies

NA

Testing

Load a page with a codeblock that has very long last line

Steps:

  1. Assert in Safari there are no horizontal scrollbars

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • Added tests - css only
  • Ran npm test, and it succeeded
  • Updated documentation if necessary

Copy link
Contributor

@mportiz08 mportiz08 left a comment

Choose a reason for hiding this comment

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

Awesome, thanks!

@hqhhuang can you also test this with the edge case that you found?

@@ -36,6 +36,8 @@ code {
content: attr(data-after-code);
}
&::before, &::after {
// ensure the pseudo elements dont fly off in space
display: block;
Copy link
Contributor

Choose a reason for hiding this comment

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

Was hoping it was something like this! :)

It's a little strange since the default display shows as block in Safari when a value isn't specified, but it seems to not be true.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a Safari bug? Running the version that has regression, In the inspector, display is set to block by default.
image

Copy link
Contributor

@hqhhuang hqhhuang left a comment

Choose a reason for hiding this comment

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

Tested and looks great with the minimized edge case as well.

Did a quick search for pseudo elements in other parts of the code base. Should we add this fix here as well?
https://github.com/apple/swift-docc-render/blob/715eb13b2fed2da840e7a8eda41ffec8248dd3c4/src/components/ContentNode/StrikeThrough.vue#L34
I couldn't find an example of where we use this component to test though.

@mportiz08
Copy link
Contributor

Tested and looks great with the minimized edge case as well.

Did a quick search for pseudo elements in other parts of the code base. Should we add this fix here as well?

https://github.com/apple/swift-docc-render/blob/715eb13b2fed2da840e7a8eda41ffec8248dd3c4/src/components/ContentNode/StrikeThrough.vue#L34

I couldn't find an example of where we use this component to test though.

I don't believe so. The strikethrough is used for inline text that looks like this and we wouldn't want to use a block display there.

@mportiz08
Copy link
Contributor

@swift-ci test

@mportiz08 mportiz08 merged commit f5e8a34 into swiftlang:main Jun 23, 2023
@mportiz08 mportiz08 deleted the dhristov/r110741983-fix-codelisting-scrollbar branch June 23, 2023 21:10
mportiz08 pushed a commit to mportiz08/swift-docc-render that referenced this pull request Jun 23, 2023
dobromir-hristov pushed a commit that referenced this pull request Jun 26, 2023
…700) (#703)

Resolves: rdar://110741983

Co-authored-by: Dobromir Hristov <[email protected]>
hqhhuang pushed a commit to hqhhuang/swift-docc-render that referenced this pull request Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants