[ui5-side-navigation-item]: expandable items with children cannot use `href` because the expand/collapse chevron is a child of the link anchor

未关闭
#14,131 1 条评论 0 个 reaction 已指派 1 人 在 GitHub 查看

维护者通常 2 天内回复

@LidiyaGeorgieva 已经在做这个了。

开始于 2026年10月29日。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
74/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript, web-dev

调研方向

Start with packages/fiori/src/SideNavigationItemTemplate.tsx to trace how the anchor and toggle icon are rendered, then read the toggle handler in packages/fiori/src/SideNavigationItem.ts. Check the component’s existing tests for expandable items and href behavior. Done when the link retains native navigation semantics while the chevron independently toggles expansion.

由索引模型根据 Issue 内容生成。

描述

bug TOPIC RD
Bug Description

When a ui5-side-navigation-item is expandable (has ui5-side-navigation-sub-item children) and an href is set, the native link and the expand/collapse chevron conflict, because the chevron toggle icon is rendered inside the anchor element rather than as a sibling.

In packages/fiori/src/SideNavigationItemTemplate.tsx the item renders roughly as:

  <EffectiveTag ... href={this._href} ...>
    <Icon .../>                                   {/* leading icon   */}
    <div class="ui5-sn-item-text">...</div>       {/* label          */}
    <Icon
      class="ui5-sn-item-toggle-icon"
      onClick={this._onToggleClick}               {/* expand/collapse */}
      .../>
    <Icon class="ui5-sn-item-external-link-icon" .../>
  </EffectiveTag>

Because the chevron lives inside the <a href>:

  • A click on the chevron is also a click on the link. _onToggleClick must stopPropagation() and rely on preventDefault plumbing to stop the anchor from navigating.
  • Native browser link behavior (middle-click, context menu "Open in new tab", "Copy link address") now also applies to the chevron area, which is irritating.
  • Consumers are effectively forced to omit href on expandable/parent items and re-implement navigation in JS to avoid the conflict which means those items lose the native link context menu entirely.
Affected Component

ui5-side-navigation-item (also ui5-side-navigation-sub-item) — package @ui5/webcomponents-fiori

Expected Behaviour

An expandable ui5-side-navigation-item should be able to carry a real href and support expand/collapse without the two interfering:

  • The chevron/toggle is a separate interactive sibling of the link anchor (its own button/role), not a descendant of the <a>.
  • The link part keeps native link semantics (new tab via modifier/middle-click, context menu, "copy link address").
  • The chevron toggles expansion independently, without requiring stopPropagation/preventDefault handling on the consumer side.
Isolated Example

No response

Steps to Reproduce
  1. Render a ui5-side-navigation-item with href set and one or more ui5-side-navigation-sub-item children.
  2. Right-click the item; the chevron area is part of the link, so the browser's link context menu covers the toggle too.
  3. Drive navigation purely via href: clicking the chevron also activates the link, so expand/collapse and navigation collide.
Log Output, Stack Trace or Screenshots

No response

Priority

Medium

UI5 Web Components Version

2.27.2

Browser

Chrome, Edge, Firefox, Safari

Operating System

No response

Additional Context

href/target support was added in PR #7682. This report is about making it usable on expandable items by separating the chevron from the anchor. The component already has a dedicated toggle handler (_onToggleClick / _toggle() in packages/fiori/src/SideNavigationItem.ts), so the chevron could be moved onto a standalone button sibling of the link with limited change to the handler logic.

Related: #11447 (stopPropagation/preventDefault on item click) and #10603 (click-detail modifiers) are symptoms of the same single-anchor-wraps-everything structure.

Organization

No response

Declaration
  • I’m not disclosing any internal or sensitive information.
主要语言
TypeScript
星标
1.8k
派生
289
平均合并
4 天 5 小时
30 天内合并 PR
33

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

UI5/webcomponents 的其他 Issue

查看 UI5/webcomponents 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。