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: Add a helper method for menu's page title #20165

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mshabarov
Copy link
Contributor

@mshabarov mshabarov commented Oct 7, 2024

Description

Adds a new static helper method that gives a page title for views shown using menu.

Fixes #20158

Type of change

  • Bugfix
  • Feature

Checklist

  • I have read the contribution guide: https://vaadin.com/docs/latest/guide/contributing/overview/
  • I have added a description following the guideline.
  • The issue is created in the corresponding repository and I have referenced it.
  • I have added tests to ensure my change is effective and works as intended.
  • New and existing tests are passing locally with my change.
  • I have performed self-review and corrected misspellings.

Additional for Feature type of change

  • Enhancement / new feature was discussed in a corresponding GitHub issue and Acceptance Criteria were created.

Copy link

sonarcloud bot commented Oct 7, 2024

Copy link

github-actions bot commented Oct 7, 2024

Test Results

  909 files  ±0    909 suites  ±0   57m 41s ⏱️ + 1m 6s
4 899 tests ±0  4 846 ✅ ±0  49 💤 ±0  4 ❌ ±0 
5 241 runs  +7  5 178 ✅ +4  59 💤 +3  4 ❌ ±0 

For more details on these failures, see this check.

Results for commit ab081f3. ± Comparison against base commit 5824994.

if (ui != null) {
String path = ui.getInternals().getActiveViewLocation().getPath();
if (path.startsWith("/")) {
path = path.substring(1);
Copy link
Member

Choose a reason for hiding this comment

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

Usage of PathUtil.trimPath could cleanup a bit.

@@ -55,6 +57,34 @@ public static List<MenuEntry> getMenuEntries(Locale locale) {
.map(MenuConfiguration::createMenuEntry).toList();
}

/**
* Get the optional page title of the currently shown view that is rendered
Copy link
Member

Choose a reason for hiding this comment

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

This is not very clear when it can and can't be used.

At least it would work when called inside After Navigation Event handler. But not if navigation happens to path with route parameter (any kind: required, optional, wildcard). Works only with paths targeting a route without any custom route parameters, like with automatic menu links.

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.

Navigating Hilla view throws getContent is null exception on flow layout hybrid application
3 participants