-
Notifications
You must be signed in to change notification settings - Fork 124
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
Add autogenerated breadcrumbs component #2193
Conversation
I managed to do it looking at the site-nav DOM, however I am currently trying to iron out 2 bugs:
Would appreciate any feedback/suggestions! |
@itsyme Good work with the PR so far!
Maybe we can try to check this by looking if the dropdown has a link or not? if the dropdown has a link just link to it, else we just look at the first link.
Not sure what could be causing this issue but it might be the following?
|
Hi @ong6! Thanks for the suggestions! I managed to fix the second issue with some breadcrumbs not appearing. It seems that for some e.g. UG -> Authoring Contents -> Reusing Contents has 1 Similarly, UG -> Authoring Contents -> Using Components -> Navigation has 2 but UG -> Authoring Contents -> Using Components -> The Rest has 1. Do you think this could be a potential bug in the |
The breadcrumbs works now! Just some small issues to iron out. I was wondering if we should visually distinguish between breadcrumbs that are clickable and those that are not. Currently, I do not distinguish between them as it made the breadcrumbs look messy. Also, do we want to have a toggle for breadcrumbs in the frontmatter or just have the user add the breadcrumb component into their layout as the toggle? |
Ideally yes, but I agree that it may look messy. I can't think of a cleaner way to go about this besides having the usual cursor-hover behaviour on links.
I think both are viable! Adding the breadcrumbs component into their layout that could offer users more flexibility and allow them to include it in the default layout. On the other hand, 90% of the time the breadcrumbs are probably in the same place, so having it as a frontmatter toggle could be more convenient. I'm leaning towards having it as a component to include in layouts since this aligns more with how we support other features like pageNavs, etc. |
Thanks for the feedback! I am doing the documentation for Breadcrumbs now and am wondering if I should put it under "Navigation" or "Others". I am leaning towards "Others" as the "Navigation" section is already very long and breadcrumbs is more a peripheral component rather than a core navigation component. What do you think? |
Hi @itsyme, thanks for the PR! I personally think that since breadcrumbs fundamentally still has to do with navigation between pages, I think putting it under the "Navigation" section still makes more sense than "Others". (As a side note, I feel like we can afford to also rename the "Others" into "Questions and Quizzes" since there's only those components described in the "Others" section) |
@itsyme For new features, also good to try them out on CS2103/T website as that's the heaviest MarkBind site we have now. |
Great work so far! What do you think about leaving those unclickable links out of the breadcrumbs completely. (don't show them all together.) My reasoning for this is because breadcrumbs are used mainly for navigation and if there is no link, perhaps there is no need to show them since they can't navigate to it anyways.
I agree with Jovyn on this point. Leaving it in layouts seems right. |
Can you also share what it looks like for longer-than-usual titles (hence a longer breadcrumb), to see if it handles that well? |
I think that leaving the unclickable links out might reduce the value that the breadcrumbs bring to the user. I find the unclickable links being displayed helps the user to track which section they currently are more easily, even if the links do not direct them to a page on click. Also, much of the sitenav dropdowns (that I have seen so far) do not contain a page. This could lead to our breadcrumb displaying only the current page majority of the time. What do you think? |
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 @itsyme , the component is working well!
Is it possible to add tests for generating the items
array from the siteNav, since the current tests stub the items
array?
I'm also wondering if we should add this to the default template 🤔 What do you think?
@@ -0,0 +1,102 @@ | |||
<template> | |||
<div> | |||
<nav aria-label="breadcrumb"> |
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 is a really nice & thoughtful accessibility consideration! Same for the aria-current
below 👍
|
||
// Identify the first site-nav-list-root | ||
// In the ideal case, there is only one site-nav-list-root | ||
// however this is not the case for all pages |
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.
:O just checking, would the other site-nav-list-root be a duplicate? Or is it possible to have multiple site-nav-list-root with different contents?
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.
From my experience, the other site-nav-list-root is a subset of the current sitenav. I feel like this is unexpected behaviour as ideally there should only be one site-nav-list-root
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 have found out why the bug is happening! I realised that the navigation page has an example sitenav in the page, resulting in the weird behaviour.
Not a big issue, but I'm getting a weird jerky change of the cursor when moving to an I'm fine with removing the class entirely since having the cursor as a caret when hovering over text seems reasonable to me, given that that's the standard cursor behaviour. Screen.Recording.2023-03-28.at.9.43.29.PM.mov |
Thanks for the review @jovyntls! I was having some issues with the tests with siteNav and might need some time to work it to get them to work. I will try to get it done ASAP! As for the default template, I think it would be a great addition! I will add it in the next commit! |
HI @jovyntls! I have made the relevant changes including generating the breadcrumbs from the sitenav component. However, because it requires a short timeout, I have skipped the tests because of issue #2238 just to be sure, but I have tested them and they work as intended. |
I see, why does it require a setTimeout? Is it to wait for the breadcrumbs to be generated after mounting? |
Yup! There needs to be a very short delay for the breadcrumbs to generate the data from the sitenav, else the snapshot will return an empty breadcrumb! |
Would the For docs, ctrl-F 'nextTick' here: https://test-utils.vuejs.org/guide/advanced/async-suspense.html#a-simple-example-updating-with-trigger Unfortunately this won't work for the other tests in #2238 since those components implicitly use setTimeouts 😢 |
Thanks for the suggestion! It worked well and I have implemented it in the latest commit and unskipped the tests! |
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! This would be a nice feature addition 🎉 Thanks @itsyme !
What is the purpose of this pull request?
Overview of changes:
Resolves #2094.
Anything you'd like to highlight/discuss:
Testing instructions:
Proposed commit message: (wrap lines at 72 characters)
Add autogenerated breadcrumbs component
Checklist: ☑️