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

use ellipsis to truncate breadcrumbs, and test with playwright #1861

Merged
merged 16 commits into from
Jun 27, 2024

Conversation

ivanov
Copy link
Contributor

@ivanov ivanov commented Jun 5, 2024

This PR:

  • Fixes breadcrumb truncation to use CSS overflow: ellipsis
  • Provides an example for combining playwright and sphinx_build_factory to more thoroughly test our theme components.
  • Applies that approach to testing breadcrumb truncation via ellipsis when the breadcrumb is placed in various parts of our layout.

joint work with @munkm and @drammock

closes #1583
closes #1568
lays groundwork for addressing #229

@drammock drammock marked this pull request as ready for review June 5, 2024 22:52
@drammock drammock changed the title breadcrumb tests use ellipsis to truncate breadcrumbs, and test with playwright Jun 5, 2024
@drammock drammock requested a review from gabalafou June 5, 2024 22:57
@gabalafou
Copy link
Collaborator

gabalafou commented Jun 6, 2024

I love this work!

Also. Breadcrumbs. Hansel. Gretel. Hehe.

I took a stab a while back at using the trinity of text-overflow: ellipsis, overflow: hidden, and white-space: nowrap, and I remember being miffed at it not working. Then I started fiddling with the display: flex on the breadcrumb ancestors, but I couldn't get it to work, and I had other priorities, and so I gave up and moved on.

So I'm sure this pull request involved quite a bit of pulling at the strings to untangle the knot.

But there's still an issue. On a narrow mobile screen, if an intermediate (i.e., not last) breadcrumb is long, it will push off the screen:

screenshot showing long intermediate breadcrumb on iPhone SE

But I think I have the fix. It requires allowing the breadcrumbs as a whole to wrap, but truncating any breadcrumb whose line goes too long. Mind if I push the commit?

(I've accounted for making sure the breadcrumbs don't bleed into the article title, as shown in #1451.)

@drammock
Copy link
Collaborator

drammock commented Jun 6, 2024

But I think I have the fix. It requires allowing the breadcrumbs as a whole to wrap, but truncating any breadcrumb whose line goes too long. Mind if I push the commit?

Go for it!

@gabalafou
Copy link
Collaborator

gabalafou commented Jun 7, 2024

With my last push, the breadcrumbs for the same page in the above screenshot now takes three lines instead of one, but any individual breadcrumb part that takes more than one line (the middle line in this example) gets truncated with an ellipsis:

Copy link
Collaborator

@gabalafou gabalafou left a comment

Choose a reason for hiding this comment

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

Left some self review comments

@@ -5,7 +5,7 @@ ul.bd-breadcrumbs {
list-style: none;
padding-left: 0;
display: flex;
flex-wrap: nowrap;
flex-wrap: wrap;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I changed this line to allow the breadcrumb component as a whole to wrap across multiple lines. (But each individual crumb can take at most one line, given the following the rules.)

@@ -14,16 +14,12 @@ ul.bd-breadcrumbs {
display: flex;
align-items: center;
white-space: nowrap;
flex-shrink: 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of flex-shrink here, I use overflow-x to make sure that the breadcrumb part can take up at most one line


&.active {
flex-shrink: 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

In my testing, this flex-shrink rule wasn't needed, so I removed it

Comment on lines +19 to +20
a,
.ellipsis {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Now the text-overflow: ellipsis rule applies to all the breadcrumbs not just the last/current one

Comment on lines -12 to -15
align-items: start;
gap: 0.5rem;
Copy link
Collaborator

Choose a reason for hiding this comment

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

These rules have no meaning after display: flex was deleted, so I deleted them.

@@ -4,13 +4,6 @@
// The items define the height so that it disappears if there are no items
.header-article-item {
min-height: var(--pst-header-article-height);
height: var(--pst-header-article-height);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Removing the height rule should prevent the issue in #1451, in which the breadcrumbs overlap the article title

@@ -9,19 +9,6 @@
playwright = pytest.importorskip("playwright")
from playwright.sync_api import Page, expect # noqa: E402

# Important note: automated accessibility scans can only find a fraction of
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like this comment was accidentally pasted here

drammock
drammock previously approved these changes Jun 11, 2024
Copy link
Collaborator

@drammock drammock left a comment

Choose a reason for hiding this comment

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

With my last push, the breadcrumbs for the same page in the above screenshot now takes three lines instead of one, but any individual breadcrumb part that takes more than one line (the middle line in this example) gets truncated with an ellipsis:

My personal feeling is that the breadcrumb should always be only one line, and we should, if necessary, elide multiple intermediate levels with ... and also truncate the final level with .... But if we're going to take the approach here (of letting breadcrumb elements be on separate lines) then we should probably (?) disable the "skipping some levels in the middle" ellipsis:

Screenshot 2024-06-11 at 11-43-35 4 3 3  Sub sub page 3 — PyData Theme 0 15 4dev0 documentation

In other words, to me the point of skipping some of the middle levels is to make it all fit on one line; if fitting on one line is no longer the goal, we shouldn't conceal intermediate levels.

Perhaps the ideal approach would be for the whole trail to be on one line, and the intermediate ... would be clickable, and when clicked, would expand the trail onto multiple lines.

All that said: unless @gabalafou fully agrees and wants to tackle that now, I'm OK to merge this as-is as a clear improvement, and transfer this comment to a new issue as a "possible future refinement"

@gabalafou
Copy link
Collaborator

My personal feeling is that the breadcrumb should always be only one line, and we should, if necessary, elide multiple intermediate levels with ... and also truncate the final level with ....

Heh, I'm curious how we ended on completely opposite preferences. In my mind, the breadcrumbs are there to help me understand where I am in the hierarchy. Having intermediate ellipses somewhat defeats that purpose. In theory (or at least in my head), the breadcrumbs become even more important on mobile because you don't have the top nav and sidebars to help you stay oriented, but if a narrow screen and a constraint to keep it on one line causes even more elision, then I begin to wonder what purpose the breadcrumb component even serves on mobile.

In other words, to me the point of skipping some of the middle levels is to make it all fit on one line

Totally agree with you here, though. :)

@drammock
Copy link
Collaborator

Heh, I'm curious how we ended on completely opposite preferences.

I think mine is aesthetic: I don't like breadcrumbs as a means of navigation, so I think they should take up as little space as possible (to stay out of my way). But my preferences should not hamstring other users' ability to navigate sites. So after some further thought, I think we should definitely remove the intermediate ellipsis, ideally as part of this PR, so that folks who do use breadcrumbs can do so effectively.

If we do re-introduce the intermediate ellipsis later, we should probably only do so if we also make them click-to-expand-able, or perhaps add a theme option whether to enable intermediate breadcrumb elision. Since both of those directions introduce considerable complexity, there should probably be some brainstorming / community input first.

@gabalafou are you up for removing the intermediate ellipsis logic? If not I can try to get back to it sometime soonish.

@gabalafou
Copy link
Collaborator

Great, agree! I cannot get to the intermediates this week, but I could get to it next week

@drammock
Copy link
Collaborator

after some further thought, I think we should definitely remove the intermediate ellipsis, ideally as part of this PR

done in b2f2510

@gabalafou ready for review/merge. (also sorry for the rebase + force-push; I rebased while attempting to fix mysterious local test failures, which turned out to have been caused by something else entirely)

@gabalafou
Copy link
Collaborator

I think it's looking good. I pushed a commit to add margin, otherwise we lose the focus ring

Copy link
Collaborator

@drammock drammock left a comment

Choose a reason for hiding this comment

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

@gabalafou I'll let you merge if you're happy. Thanks @ivanov and @munkm !!

@Carreau
Copy link
Collaborator

Carreau commented Jun 19, 2024

I'm guessing this shoudl wait for 0.15.4 right ?

@trallard trallard added tag: CSS CSS and SCSS related issues tag: testing Issues related to PST testing labels Jun 25, 2024
@Carreau
Copy link
Collaborator

Carreau commented Jun 27, 2024

0.15.4 is out, merging.

@Carreau Carreau merged commit 11e0411 into pydata:main Jun 27, 2024
29 checks passed
@gabalafou
Copy link
Collaborator

Just wondering, were the tests added in this PR still passing after all of the changes we made? Seems odd...

@drammock
Copy link
Collaborator

drammock commented Jul 8, 2024

Just wondering, were the tests added in this PR still passing after all of the changes we made? Seems odd...

the late-breaking changes (letting each breadcrumb item be on its own line) are unlikely to have broken the tests because the test was extreme about setting very large (1440px) & very small (150 px) viewports to trigger the absence/presence of ellipsis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tag: CSS CSS and SCSS related issues tag: testing Issues related to PST testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

regression: breadcrumbs truncated regardless of screen size
5 participants