-
Notifications
You must be signed in to change notification settings - Fork 91
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
feat(chrome)!: improves markup structure for Nav
items
#1784
Conversation
Nav.Item
s
Nav.Item
sNav
items
bcc89e3
to
2911b79
Compare
display: flex; | ||
flex: 1; | ||
flex-direction: column; | ||
order: -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CSS order
rules can lead to accessibility problems and I've had mixed experiences with them. Do we still need these rules or should we leave it to the user to specify the correct order (potential breaking change π₯)?
https://developer.mozilla.org/en-US/docs/Web/CSS/order#accessibility_concerns
https://www.w3.org/TR/css-flexbox-1/#order-accessibility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, you just jogged my senses a bit. Since this element is just a ul
and it's a container, it shouldn't land in an unexpected render order. So, we can probably just remove these I think? π€
I'll give it a quick test to confirm, and we can discuss inconsistencies if there are any!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I see why order
is used here.
It's to ensure that a child composition of:
<Nav>
<Nav.List>
<Nav.Item hasBrandmark />
<Nav.Item>
<Nav.ItemText />
<Nav.ItemIcon />
</Nav.Item>
<Nav.Item hasLogo />
</Nav.List>
</Nav>
Renders in the expected way in the DOM:
<nav>
<ul>
<li class="StyledLogoItem /> <!-- logo first -->
<li class="StyledItem">
<span class="StyledItemIcon" /> <!-- icon first -->
<span class="StyledItemText" />
</li>
<li class="StyledBrandmarkItem" /> <!-- brandmark last -->
</ul>
</nav>
E.g., a break-prevention measure. I can't speak to if this is still desirable though. I assume so but maybe JZ or design have further insights. I would agree it is a bit heavy-handed but I can understand the logic after toying with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And now I see that removing order: -1
from <Nav>
also changes the above ^ behavior in this PR vs. main
/next
, which I'll revert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your excellent explanation. π― It looks like removing order
isn't so trivial after all and definitely falls out of scope for this PR. Perhaps something we can revisit in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree on revisiting if it makes sense!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The order
CSS throughout Chrome is intentional, and despite the a11y concerns we keep it because enforcing consistent UX tab ordering despite consumer usage is the more important concern. Perhaps if/when a grid layout vs. flex is explored in the future, we can reevaluate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM π₯ π
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In accordance with the a11y issue we're attempting to address, we're looking for logo and brandmark items to live outside the list. Expecting to see:
<Nav>
<Nav.Item hasLogo />
<Nav.List>
<Nav.Item ... />
<Nav.Item ... />
<Nav.Item ... />
</Nav.List>
<Nav.Item hasBrandmark />
</Nav>
This means <Nav.Item>
will need context to understand whether to render a <li>
or not.
96cfb95
to
eee833a
Compare
Thanks @jzempel - that detail wasn't immediately clear to me from our previous conversations. I recall you mentioned context but I didn't connect that to the logo/brandmark items being excluded from the list. Should be updated now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, with minor URL comment for consideration.
docs/migration.md
Outdated
@@ -76,6 +76,9 @@ consider additional positioning prop support on a case-by-case basis. | |||
- `CollapsibleSubNavItem` -> `SubNav.CollapsibleItem` | |||
- `SubNavItem` -> `SubNav.Item` | |||
- `SubNavItemText` -> `SubNav.ItemText` | |||
- Added `Nav.List` as a semantic wrapper for `Nav.Item`. See | |||
[README](https://github.com/zendeskgarden/react-components/blob/main/packages/chrome/README.md#usages) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a relative path so that it is valid whether on next
or main
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I wasn't sure if that was possible here. Good call. I'll update and test it before I merge!
For consistency, it might be good to use the dot notation in this story:
|
Dang @ze-flo amazing snipe on that pattern file! haha |
Nav
itemsNav
items
Description
Introduces
Nav.List
subcomponent for a semantically accurate navigation list.Detail
Nav.List
as a wrapper forNav.Item
Nav.Item
is within aNav.List
, and if so, includes a styledli
Nav.List
New composition API:
Checklist
π design updates will be Garden Designer approved (add the designer as a reviewer)npm start
)?bedrock
)