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

Expose active trigger width and offset in NavigationMenuViewport #2893

Open
onursagir opened this issue May 10, 2024 · 0 comments
Open

Expose active trigger width and offset in NavigationMenuViewport #2893

onursagir opened this issue May 10, 2024 · 0 comments

Comments

@onursagir
Copy link

Feature request

Overview

Currently NavigationMenu.Viewport does not expose the position or the width of the active trigger, which makes it difficult to position the submenu if the subemenu is smaller than the navigation bar. Currently it is possible hack your way around this by using the NavigationMenu.Indicator like i have done here however this does lead to other issues like setting min-width and text appearing on wrong places when mounting.

        <NavigationMenu.Indicator forceMount className={styles.indicator}>
          <div>
            <div className="absolute left-1/2 z-50 h-3 w-3 -translate-x-1/2 -translate-y-1/2 rotate-45 bg-primary-main" />
            <div className="absolute left-0 top-full flex">
              <NavigationMenu.Viewport
                forceMount
                style={{
                  height: 'var(--radix-navigation-menu-viewport-height)',
                  width: 'var(--radix-navigation-menu-viewport-width)',
                }}
              />
            </div>
          </div>
        </NavigationMenu.Indicator>

Examples in other libraries

I guess this library already has the logic for it. packages/react/navigation-menu/src/NavigationMenu.tsx

          ? {
              left: 0,
              width: position.size + 'px',
              transform: `translateX(${position.offset}px)`,
            }
          : {
              top: 0,
              height: position.size + 'px',
              transform: `translateY(${position.offset}px)`,
            }),

Who does this impact? Who is this for?

This is for people who need to integrate submenu navigation which are smaller than the navbar.

Additional context

You can see what I mean on regels.overheid.nl

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

No branches or pull requests

1 participant