Skip to content

feat: add root heading level support to dashboard layout #9249

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ugur-vaadin
Copy link
Contributor

Description

This PR adds root heading level support to DashboardLayout. It was previously added for Dashboard. This PR also refactors the heading level logic in Dashboard, DashboardWidget, and DashboardSection; centralizing them in DashboardLayoutMixin and DashboardItemMixin.

Fixes #8924

Type of change

  • Bugfix
  • Feature

Checklist

  • I have read the contribution guide: https://vaadin.com/docs/latest/contributing/pr
  • 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.
  • Enhancement / new feature was discussed in a corresponding GitHub issue and Acceptance Criteria were created.

this.__removeHeadingLevelObserver();
const parentLayout = getParentLayout(this);
if (parentLayout) {
this.__headingLevelObserver = new MutationObserver(() => this.__updateRootHeadingLevel());
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we just fire an event when the heading level changes? MIght be a bit more light-weight than creating a mutation observer per item instance.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ugur-vaadin Did you plan to address this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the PR to use an event instead of a MutationObserver.

*/
export function getParentLayout(node) {
return __findFilteredAncestorInstance(node, (el) => {
return el.constructor && el.constructor.toString().includes('DashboardLayoutMixin');
Copy link
Contributor

Choose a reason for hiding this comment

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

This probably won't work in production where function and class names get minified. Did a quick test in a Flow project and "DashboardLayoutMixin" does not show up in any generated chunks. Since there are only two types of elements to test for, we could use the is getter to check for the tag name:

static get is() {
return 'vaadin-dashboard';
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated the helper to use is.

Copy link
Contributor

Choose a reason for hiding this comment

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

@web-padawan Since you noted this in the other PR, should we prefer localName over is?

@ugur-vaadin ugur-vaadin force-pushed the feat-add-root-level-heading-support-to-dashboard-layout branch from a0088af to e9590b4 Compare June 4, 2025 06:30
ugur-vaadin and others added 3 commits June 4, 2025 11:54
Copy link

sonarqubecloud bot commented Jun 6, 2025

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

Successfully merging this pull request may close these issues.

[dashboard-layout] Add suppport for root level heading API
3 participants