fix: breadcrumb links without href should not have hover styles#266
Conversation
|
Hi @srmagura! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
✅ Deploy Preview for infima ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
slorber
left a comment
There was a problem hiding this comment.
Agree this UX is not ideal and we should change it.
Breadcrumb items do not necessarily have an href, but they always change color when the user hovers over them.
In practice it's more:
breadcrumb items might be simple
<span>instead of<a>when we don't have a link
Not 100% sure using :link is the solution here?
Also worth adding a test to our demo page here: https://deploy-preview-266--infima.netlify.app/demo/
We only have breadcrumb items with links currently (unlike what we have on the Docusaurus side in practice). Please try to add something here that helps reviewing the current PR.
| @mixin transition background color; | ||
|
|
||
| &:hover { | ||
| &:link:hover { |
There was a problem hiding this comment.
The :link CSS pseudo-class represents an element that has not yet been visited.
Does it mean that we'll lose the hover effect once the link is visited? 😅
Maybe using :is(a):hover would be better? (90% support good enough for this usecase)
TIL there's also an :any-link pseudo-selector, looks like a potential good fit?
There was a problem hiding this comment.
Great tip regarding :any-link. I had no idea :link was only for unvisited links — that's really poor design.
| @mixin transition color; | ||
|
|
||
| &:hover { | ||
| &:link:hover { |
There was a problem hiding this comment.
🤷♂️ this one looks more general and not sure it's directly related to your problem, considering the element is already a <a> there?
Can it have unwanted side effects? + not sure :link is what we want anyway
There was a problem hiding this comment.
You can have <a> elements that don't represent links (like headings). It usually only makes sense to display hover styles if the <a> represents a link.
This change was also necessary to prevent the color of the breadcrumb item from changing when hovered.
There was a problem hiding this comment.
I see, what I understand is we don't want the text color to change on hover in this demo:
https://deploy-preview-266--infima.netlify.app/demo/#breadcrumbs
|
Thanks for the feedback. I switched to
True, but I assume you would not want hover styles if the breadcrumb item is a |
diff --git a/packages/core/dist/css/default/default.css b/packages/core/dist-branch/css/default/default.css
index 95fc6e3..f258e29 100644
--- a/packages/core/dist/css/default/default.css
+++ b/packages/core/dist-branch/css/default/default.css
@@ -1233,[7](https://github.com/facebookincubator/infima/runs/7197269101?check_suite_focus=true#step:4:7) +1233,25 @@ a {
transition: color var(--ifm-transition-fast) var(--ifm-transition-timing-default);
}
-a:hover {
+a:link:hover, a:visited:hover {
+ color: var(--ifm-link-hover-color);
+ /* autoprefixer: ignore next */
+ text-decoration: var(--ifm-link-hover-decoration);
+ }
+
+a:-webkit-any-link:hover {
+ color: var(--ifm-link-hover-color);
+ /* autoprefixer: ignore next */
+ text-decoration: var(--ifm-link-hover-decoration);
+ }
+
+a:-moz-any-link:hover {
+ color: var(--ifm-link-hover-color);
+ /* autoprefixer: ignore next */
+ text-decoration: var(--ifm-link-hover-decoration);
+ }
+
+a:any-link:hover {
color: var(--ifm-link-hover-color);
/* autoprefixer: ignore next */
text-decoration: var(--ifm-link-hover-decoration);
@@ -172[8](https://github.com/facebookincubator/infima/runs/7197269101?check_suite_focus=true#step:4:8),7 +1746,22 @@ hr {
transition-timing-function: var(--ifm-transition-timing-default);
}
-.breadcrumbs__link:hover {
+.breadcrumbs__link:link:hover, .breadcrumbs__link:visited:hover, area.breadcrumbs__link[href]:hover {
+ background: var(--ifm-breadcrumb-item-background-active);
+ text-decoration: none;
+ }
+
+.breadcrumbs__link:-webkit-any-link:hover {
+ background: var(--ifm-breadcrumb-item-background-active);
+ text-decoration: none;
+ }
+
+.breadcrumbs__link:-moz-any-link:hover {
+ background: var(--ifm-breadcrumb-item-background-active);
+ text-decoration: none;
+ }
+
+.breadcrumbs__link:any-link:hover {
background: var(--ifm-breadcrumb-item-background-active);
text-decoration: none;
} |
|
@Josh-Cena Why are those changes necessary? I tested in Chrome, Safari, and Firefox and the vendor prefixes were not necessary. |
|
Ah, no, that's the "post diff comment" workflow's result 😄 It can't be posted on PRs created from forks, so I manually post it so we know how the distributed CSS has changed. See #255 (comment) for example. |
|
Ooooohhhhh, OK. Do I need to do anything to get that workflow to pass? |
|
No, it's a problem with our workflow plus some permission quirks. It's mostly okay this way. |
|
LGTM thanks 👍 |
href not have hover styleshref should not have hover styles
| &:any-link:hover { | ||
| color: var(--ifm-link-hover-color); | ||
| /* autoprefixer: ignore next */ | ||
| text-decoration: var(--ifm-link-hover-decoration); |
There was a problem hiding this comment.
I guess this is causing text-decoration: underline for all links including buttons, sidebar menu, navbar, navbar dropdown menu. facebook/docusaurus#7748
There was a problem hiding this comment.
Adding the any-link pseudo selector increases the specificity, now a:any-link:hover is more specific than other selectors like button:hover
There was a problem hiding this comment.
Thanks for pointing this out.

Breadcrumb items do not necessarily have an
href, but they always change color when the user hovers over them. The hover styles give the impression that the breadcrumb item is a clickable link even if this is not the case.This can be seen in the Redux documentation — neither "Tutorials" nor "Redux Essentials" are links, yet they have hover styles.
This PR uses the
:linkpseudoselector to fix this.Edit: Signed the CLA.