Skip to content

Conversation

@adrianjm-dotCMS
Copy link

Description

This PR introduces an enhanced click behavior for nav-items to provide more control over group expansion and navigation.

The dot-nav-item component has been refactored to be split into two distinct clickable areas:

  • Main Area (first 2/3): Retains the default behavior. Clicking here will expand the group and navigate to the first item (or perform its default action).
  • Toggle Area (last 1/3): This new, smaller area is dedicated only to expanding or collapsing the group. It does not trigger navigation.

Changes Made

  • dot-nav-item.component.html

    • Updated the template to include the new two-div structure (for the main and toggle areas), identified by data-testid attributes.
  • dot-nav-item.component.scss

    • Added new styles to support the 2/3 and 1/3 layout and the new interactive zones.
  • dot-nav-item.component.ts

    • Created a new toggleHandler method to manage clicks on the new toggle area.
    • The existing menuClick emitter is reused. When the toggle area is clicked, it now emits menuClick with an optional toggleOnly: true flag.
    • Clicks on the main area emit menuClick without the toggleOnly flag, preserving the original functionality.
    • stopPropagation() is called on toggle clicks to prevent the event from bubbling up.

Tests

  • dot-nav-item.component.spec.ts
    • Added new tests to verify that both the main and toggle areas are rendered correctly.
    • Confirms that menuClick emits with toggleOnly: true when the toggle area is clicked.
    • Confirms that menuClick emits without the toggleOnly flag when the main area is clicked.
    • Ensures that event.stopPropagation() is correctly called on toggle area clicks.

Demo

Please see the video below demonstrating the new split-click behavior.

PR23381.mp4

This PR fixes #32017

align-items: center;
cursor: pointer;
display: flex;
padding: 14px 0 13px 25px;
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

Okay, now I'm using the spacing variables, but I'm using the closest values since they are not exact. It's just a 1px or 2px difference, but I'm not sure if we are going to have an issue with the design.

cursor: pointer;
display: flex;
justify-content: center;
padding: 14px 22px 13px 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, use the ones that are more close to the value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Different targets for navigation groups in the main navigation

4 participants