[feat]: add `aria-orientation` support to `TabsAriaController`

未关闭
#3,165 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
1-2 天
新手友好度
57/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
活跃
技术栈
typescript

调研方向

Start with core/pfe-core/controllers/tabs-aria-controller.ts and trace how pf-v5-tabs supplies its tablist and vertical state, then check how RovingTabindexController reads orientation. Implementing this spans controller ownership, component wiring, runtime orientation changes, and SSR behavior; the issue names controller tests as the place to cover horizontal, vertical, and switching orientation. Done when the tablist exposes the correct orientation and keyboard navigation follows it.

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

描述

accessibility feature priority: low

Summary

TabsAriaController does not set aria-orientation on the tablist, and nothing wires a tabs element's vertical/horizontal state into the accessibility tree.

Current state

TabsAriaController (core/pfe-core/controllers/tabs-aria-controller.ts) only:

  • sets role="tab" and role="tabpanel" on slotted children
  • sets aria-controls and aria-labelledby in hostUpdated()

It never touches the tablist itself. In pf-v5-tabs, the tablist is an inner <div id="tabs" role="tablist"> with no aria-orientation, while the element has a vertical boolean that only drives styling.

// tabs-aria-controller.ts
hostUpdated(): void {
  for (const [tab, panel] of this.#tabPanelMap) {
    panel.setAttribute('aria-labelledby', tab.id);
    tab.setAttribute('aria-controls', panel.id);
  }
}

Problems

  1. Missing ARIA state. A vertical tablist has no aria-orientation="vertical", so assistive tech reports the wrong orientation. Per the ARIA spec, aria-orientation defaults to horizontal on tablist, so a vertical tablist is actively announced incorrectly.

  2. Keyboard behavior is not orientation-aware. ATFocusController.onKeydown reads aria-orientation from the items container to decide which arrow keys move focus:

    const orientation = this.options.getOrientation?.() ?? this
        .#itemsContainerElement
        ?.getAttribute('aria-orientation') as
            'horizontal' | 'vertical' | 'grid' | 'undefined';
    

    Because the tablist never has the attribute and pf-v5-tabs does not pass getOrientation to RovingTabindexController, both Left/Right and Up/Down move focus in a horizontal tablist. The APG tabs pattern expects Left/Right for horizontal tablists and Up/Down for vertical ones.

  3. Duplicated ownership. role="tablist" is hardcoded in the pf-v5-tabs render while the rest of the tabs ARIA is managed by the controller. This split makes it easy for one side to drift from the other.

Proposed direction

  • Add tablist ARIA management to TabsAriaController, including aria-orientation.
  • Accept an orientation source in TabsAriaControllerOptions, for example orientation?: 'horizontal' | 'vertical' or getOrientation?: () => 'horizontal' | 'vertical', and reflect it to aria-orientation on the tablist (omit the attribute for the horizontal default, or set it explicitly, whichever the team prefers).
  • Give the controller a way to reference the tablist element. Since the host is not the tablist in pf-v5-tabs, this likely needs an option such as getTabList?: () => HTMLElement | null, or a documented contract that the host itself carries role="tablist".
  • Feed the same orientation to RovingTabindexController via getOrientation, or rely on the attribute once the controller sets it on the items container.
  • Consider moving role="tablist" ownership into the controller as part of this change.
  • Keep the SSR path safe (isServer guard) and add controller tests covering horizontal, vertical, and switching orientation at runtime.

Impacted components

  • core/pfe-core/controllers/tabs-aria-controller.ts
  • elements/pf-v5-tabs
  • <pf-v6-tabs> implementation in #3040

Related issues

  • #3040

Jira Issue: FELT-5230

主要语言
TypeScript
星标
397
派生
109
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

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

patternfly/patternfly-elements 的其他 Issue

查看 patternfly/patternfly-elements 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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