-
-
Notifications
You must be signed in to change notification settings - Fork 7.1k
feat(VBreadcrumbs): improve accessibility and add menu when collapsed #22358
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
base: dev
Are you sure you want to change the base?
feat(VBreadcrumbs): improve accessibility and add menu when collapsed #22358
Conversation
| return typeof item === 'string' ? { item: { title: item }, raw: item } : { item, raw: item } | ||
| })) | ||
| const showEllipsis = computed(() => items.value.length >= props.maxItems) | ||
| const enableEllipsis = ref(showEllipsis.value) |
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.
This prevents the limit from being responsive. Let's say I resize the window and the limit changes, it won't be reflected until the component or page is fully refreshed.
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.
agree. I added a watcher on showEllipsis to handle the responsive behavior.
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.
If we leave it like this, it will only support on/off change while someone might want to change the limit based on the available width (e.g. `:total-visible='$vuetify.display.smAndUp ? 4 : 2').
BTW. it might be a personal preference, but I feel like those variables names should swap:
showEllipsis»ellipsisEnabledenableEllipsis»showEllipsisorhasEllipsis
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.
Yes, I'll renamed it
ffc8c40 to
2a3bd3e
Compare
2a3bd3e to
c77b459
Compare
| default: () => ( | ||
| <VList> | ||
| { items.value.slice(1, items.value.length - 1).map(({ item }, index) => ( | ||
| <VListItem key={ index } value={ index } component="a" href={ 'href' in item ? item.href : undefined }> |
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.
Not sure if component="a" does anything here as href should be enough to make it into <a>.
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.
Right, component="a" is useless. I remove it
| <VMenu activator="parent"> | ||
| {{ | ||
| default: () => ( | ||
| <VList> |
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.
- Would we benefit from
menu-propsandlist-propspass-through (like in VSelect)? #list-itemslot could be a reasonable addition
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.
good idea. I add it
8e6df67 to
ffe3825
Compare
ffe3825 to
d9084ec
Compare
Description
This PR improves the
VBreadcrumbscomponent with several accessibility-focused and Material Design–aligned enhancements.It now uses proper semantic elements (nav, ol, li) for improved screen-reader support and better compliance with accessibility standards.
The component automatically wraps to a new line when the breadcrumb trail becomes too long, preventing layout overflow.
A new
maxItemsprop allows developers to define how many items can be displayed before collapsing the middle items into an ellipsis.When collapsed, an optional
collapseInMenuprop enables displaying the hidden items inside an accessible dropdown menu.You can also customize the appearance of the items inside the collapsed menu using the
list-itemslot. This slot gives you access to each breadcrumb item and its index, allowing you to render any custom content for better UX and visual consistency.These additions provide cleaner navigation, improved responsiveness, and more robust UX on pages with deep hierarchies.
Markup: