iter: d21 无障碍收尾(aria-label / role / aria-hidden)

This commit is contained in:
ui-arch-bot
2026-10-23 17:03:02 +08:00
parent 9cfdb43a4f
commit 00a6104f84
10 changed files with 24 additions and 10 deletions
+2 -1
View File
@@ -6,7 +6,7 @@ export function tabs(props: TabsProps): HTMLElement {
// —— 状态集中声明 ——
const buttons: HTMLButtonElement[] = []; // 页签按钮,顺序与 tabs 一致
const indicator = h('span', { class: 'ua-tabs-indicator' });
const head = h('div', { class: 'ua-tabs-head', role: 'tablist' }, indicator);
const head = h('div', { class: 'ua-tabs-head', role: 'tablist', 'aria-label': '标签页' }, indicator);
/*** 同步激活态与指示条几何位置 ***/
const sync = () => {
@@ -27,6 +27,7 @@ export function tabs(props: TabsProps): HTMLElement {
const btn = h('button', { class: 'ua-tab', role: 'tab', type: 'button' }, tab.label) as HTMLButtonElement;
btn.dataset.value = tab.value;
btn.disabled = tab.disabled ?? false;
if (tab.disabled) btn.setAttribute('aria-disabled', 'true'); // 读屏提示不可选
btn.addEventListener('click', () => {
if (btn.disabled) return; // 卫语句:禁用页签不响应
if (props.active) props.active(tab.value); // 用户切换写回信号