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

feat(menu): allow overriding home item in breadcrumbs #2848

Merged
merged 2 commits into from
Mar 19, 2024

Conversation

vicgeralds
Copy link
Contributor

Adds a new property rootItem to limel-menu for specifying the first item when showing breadcrumbs.

If specified, the breadcrumbs will always be shown. Otherwise, the breadcrumbs are only shown when a sub-menu is open.

Review:

  • Commits are atomic
  • Commits have the correct type for the changes made
  • Commits with breaking changes are marked as such

Browsers tested:

(Check any that applies, it's ok to leave boxes unchecked if testing something didn't seem relevant.)

Windows:

  • Chrome
  • Edge
  • Firefox

Linux:

  • Chrome
  • Firefox

macOS:

  • Chrome
  • Firefox
  • Safari

Mobile:

  • Chrome on Android
  • iOS

Copy link

Documentation has been published to https://lundalogik.github.io/lime-elements/versions/PR-2848/

@vicgeralds vicgeralds requested a review from TommyLindh2 March 14, 2024 15:45
@vicgeralds vicgeralds force-pushed the menu-home-breadcrumb branch from f516491 to 7a1ca53 Compare March 14, 2024 15:49
@vicgeralds vicgeralds requested a review from a team as a code owner March 14, 2024 15:49
} as MenuCrumbItem);
if (
breadCrumbItems.length ||
this.rootItem !== DEFAULT_ROOT_BREADCRUMBS_ITEM
Copy link
Contributor

Choose a reason for hiding this comment

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

This means that you'd have to add a custom root item even though you might just want to show the default? Should we make it possible to just choose to show the root item?

Copy link
Contributor Author

@vicgeralds vicgeralds Mar 14, 2024

Choose a reason for hiding this comment

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

Yes, but I think it's not very good to just show the default. It has no text and shows an empty tooltip. Showing a generic icon that works well everywhere is difficult, and default text is difficult because it needs to be translated.

So to use breadcrumbs, I think this needs to be provided.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little unsure how to interpret the above. It sounds like you are describing a breaking change, but since the examples are still working as expected, and you haven't had to update any of them in this PR, I assume it's not actually a breaking change? 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It’s not a breaking change. I’m just complaining a bit about the default home item that’s rendered with an empty tooltip text. It’s better than nothing if you’re showing a sub menu, but I think you’d always want to replace it by providing rootItem.

There is a slight inconsistency introduced by always showing the breadcrumbs when rootItem is provided, not just after navigating to a submenu. I think this is better, because it means the position of the menu items doesn’t jump up/down when navigating between submenus and root menu.

@@ -262,8 +274,7 @@ export class Menu {
}
}

@Watch('currentSubMenu')
protected currentSubMenuWatcher() {
private getBreadcrumbsItems() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Will this still reflect the content of the menu now that we're not longer watching for changes and re-rendering the breadcrumbs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, because currentSubMenu is a (mutable) prop. So we will always re-render when it changes, and we will always call this.getBreadcrumbsItems() when rendering. It simplifies things to remove the watcher, and it also means breadcrumbs are rendered on first render, rather than only when currentSubMenu changes.

@vicgeralds vicgeralds enabled auto-merge (rebase) March 19, 2024 11:18
@vicgeralds vicgeralds merged commit 2cb1c4e into main Mar 19, 2024
11 checks passed
@vicgeralds vicgeralds deleted the menu-home-breadcrumb branch March 19, 2024 11:32
@lime-opensource
Copy link
Collaborator

🎉 This PR is included in version 37.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants