Skip to content

fix(nav-rail): hide tooltip that repeats a visible label (CORE-2785) - #512

Open
yamamporiya wants to merge 1 commit into
mainfrom
feat/CORE-2785
Open

yamamporiya wants to merge 1 commit into
mainfrom
feat/CORE-2785

Conversation

@yamamporiya

Copy link
Copy Markdown
Collaborator

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Related Tickets & Documents

https://wallarm.atlassian.net/browse/CORE-2785

@ispashkov ispashkov left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Problem. disabled on Tooltip changes with mode. Say the pointer is resting on an item and the rail goes collapsed → expanded → collapsed. After that, the tooltip on that item never opens again. While disabled is set, zag ignores pointerleave, so its internal hasPointerMoveOpened flag never resets (see the comment in Tooltip.tsx:71). I reproduced this with a test. Swapping disabled for open={false} doesn't fix it. Lint is also failing on formatting.

Fix (verified: the repro and all NavRail tests pass). Don't mount Tooltip when there's nothing to show:

const hasShortcut = !!shortcut?.length;
const trigger = props['aria-haspopup'] ? <span className='flex flex-1'>{element}</span> : element;
// A visible label without a shortcut leaves the tooltip nothing to add.
if (showsLabel && !hasShortcut) return trigger;

return (
  <Tooltip positioning={{ placement: 'right' }}>
    <TooltipTrigger asChild>{trigger}</TooltipTrigger>
    <TooltipContent>
      {!showsLabel && label}
      {!showsLabel && hasShortcut && ' '}
      {shortcut?.map((key, index) => (
        <Fragment key={key}>
          {index > 0 && ' then '}
          <Kbd size='small'>{key}</Kbd>
        </Fragment>
      ))}
    </TooltipContent>
  </Tooltip>
);

Also:

  1. Add tests to NavRail.test.tsx:
    • expanded without a shortcut: no tooltip;
    • expanded with a shortcut: Kbd only;
    • collapsed: label and shortcut;
    • compact + avatar: the user's name;
    • regression: change mode while hovered, then the tooltip still opens.
  2. Run pnpm lint:fix.
  3. Rename the PR to fix(nav-rail): hide tooltip that repeats a visible label (CORE-2785).

@yamamporiya yamamporiya changed the title fix(core-2785): menu hint fix(nav-rail): hide tooltip that repeats a visible label (CORE-2785) Nov 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR is included in version 4.20.2-rc-feat-CORE-2785.1

This branch has not been deployed

No deployments
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.

2 participants