Skip to content

Commit dcf600e

Browse files
committed
feat: improve a11y when table header is empty
1 parent 95528b8 commit dcf600e

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

src/PickerPanel/DatePanel/index.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,13 @@ export default function DatePanel<DateType extends object = any>(props: DatePane
9898
: []);
9999

100100
if (prefixColumn) {
101-
headerCells.push(<th key="empty" aria-label="empty cell" />);
101+
headerCells.push(
102+
<th key="empty">
103+
<span style={{ width: 0, height: 0, position: 'absolute', overflow: 'hidden', opacity: 0 }}>
104+
Week
105+
</span>
106+
</th>,
107+
);
102108
}
103109
for (let i = 0; i < WEEK_DAY_COUNT; i += 1) {
104110
headerCells.push(<th key={i}>{weekDaysLocale[(i + weekFirstDay) % WEEK_DAY_COUNT]}</th>);

tests/__snapshots__/panel.spec.tsx.snap

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3395,9 +3395,13 @@ exports[`Picker.Panel append cell with cellRender in week 1`] = `
33953395
>
33963396
<thead>
33973397
<tr>
3398-
<th
3399-
aria-label="empty cell"
3400-
/>
3398+
<th>
3399+
<span
3400+
style="width: 0px; height: 0px; position: absolute; overflow: hidden; opacity: 0;"
3401+
>
3402+
Week
3403+
</span>
3404+
</th>
34013405
<th>
34023406
Su
34033407
</th>
@@ -6954,9 +6958,13 @@ exports[`Picker.Panel override cell with cellRender in week 1`] = `
69546958
>
69556959
<thead>
69566960
<tr>
6957-
<th
6958-
aria-label="empty cell"
6959-
/>
6961+
<th>
6962+
<span
6963+
style="width: 0px; height: 0px; position: absolute; overflow: hidden; opacity: 0;"
6964+
>
6965+
Week
6966+
</span>
6967+
</th>
69606968
<th>
69616969
Su
69626970
</th>

0 commit comments

Comments
 (0)