Skip to content

fix: support submenu item title#868

Merged
afc163 merged 1 commit into
react-component:masterfrom
biubiukam:fix-submenu-item-title
Jun 20, 2026
Merged

fix: support submenu item title#868
afc163 merged 1 commit into
react-component:masterfrom
biubiukam:fix-submenu-item-title

Conversation

@biubiukam

Copy link
Copy Markdown
Contributor

What changed

  • Preserve items[].title for submenu items as itemTitle while keeping label as rendered submenu content.
  • Use itemTitle for the submenu title DOM attribute when present.
  • Add a regression test for submenu items with different label and title.

Why

In the items conversion path, submenu items spread rest props and then set title={label}. That overwrote a configured title, so downstream consumers could not distinguish display label from native title text.

Related

Validation

  • npm run lint (0 errors, existing warnings)
  • ./node_modules/.bin/tsc --noEmit --pretty false
  • ./node_modules/.bin/prettier --check src/SubMenu/index.tsx src/interface.ts src/utils/nodeUtil.tsx tests/Options.spec.tsx
  • npm test -- --runInBand
  • npm run coverage -- --runInBand
  • npm run compile

@biubiukam

Copy link
Copy Markdown
Contributor Author

close ant-design/ant-design#48850

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for a custom title property on submenus (SubMenuType), allowing users to specify a native HTML title attribute for submenus without overriding the display label. This is achieved by introducing an itemTitle prop to SubMenuProps and resolving it in the DOM element's title attribute. A corresponding unit test has been added to verify this behavior. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.72%. Comparing base (9c994fc) to head (82574f0).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #868   +/-   ##
=======================================
  Coverage   99.72%   99.72%           
=======================================
  Files          26       26           
  Lines         732      734    +2     
  Branches      204      205    +1     
=======================================
+ Hits          730      732    +2     
  Misses          2        2           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@biubiukam

Copy link
Copy Markdown
Contributor Author

@MadCcc 这个 PR 是否需要调整呢

@afc163 afc163 merged commit 282f38b into react-component:master Jun 20, 2026
7 checks passed
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