Skip to content

Commit 3f51e93

Browse files
committed
update some prop desc, remove default aria label and add warning if not passed, rename thprops
1 parent 1ddd1e4 commit 3f51e93

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

packages/module/src/DataViewTableHead/DataViewTableHead.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const DataViewTableHead: FC<DataViewTableHeadProps> = ({
3737
content={isDataViewThObject(column) ? column.cell : column}
3838
resizableProps={isDataViewThObject(column) ? column.resizableProps : undefined}
3939
data-ouia-component-id={`${ouiaId}-th-${index}`}
40-
props={isDataViewThObject(column) ? (column?.props ?? {}) : {}}
40+
thProps={isDataViewThObject(column) ? (column?.props ?? {}) : {}}
4141
hasResizableColumns={hasResizableColumns}
4242
/>
4343
))

packages/module/src/DataViewTh/DataViewTh.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ export interface DataViewThResizableProps {
2727
increment?: number;
2828
/** Increment for keyboard navigation while shift is held */
2929
shiftIncrement?: number;
30-
/** Aria label for the resize button */
30+
/** Provides an accessible name for the resizable column via a human readable string. */
3131
resizeButtonAriaLabel?: string;
32-
/** Screenreader text for the column */
32+
/** Screenreader text that gets announced when the column is resized. */
3333
screenReaderText?: string;
3434
}
3535
export interface DataViewThProps {
@@ -40,15 +40,15 @@ export interface DataViewThProps {
4040
/** @hide Indicates whether the table has resizable columns */
4141
hasResizableColumns?: boolean;
4242
/** Props passed to Th */
43-
props?: ThProps;
43+
thProps?: ThProps;
4444
}
4545

4646
export const DataViewTh: FC<DataViewThProps> = ({
4747
content,
4848
resizableProps = {},
4949
hasResizableColumns = false,
50-
props: thProps,
51-
...restProps
50+
thProps,
51+
...props
5252
}: DataViewThProps) => {
5353
const thRef = useRef<HTMLTableCellElement>(null);
5454

@@ -57,7 +57,7 @@ export const DataViewTh: FC<DataViewThProps> = ({
5757
const isResizable = resizableProps?.isResizable || false;
5858
const increment = resizableProps?.increment || 5;
5959
const shiftIncrement = resizableProps?.shiftIncrement || 25;
60-
const resizeButtonAriaLabel = resizableProps?.resizeButtonAriaLabel || `Resize ${content}`;
60+
const resizeButtonAriaLabel = resizableProps?.resizeButtonAriaLabel;
6161
const onResize = resizableProps?.onResize || undefined;
6262
const screenReaderText = resizableProps?.screenReaderText || `Column ${width.toFixed(0)} pixels`;
6363

@@ -67,6 +67,11 @@ export const DataViewTh: FC<DataViewThProps> = ({
6767
const isResizing = useRef(false);
6868
const isInView = useRef(true);
6969

70+
if (isResizable && !resizeButtonAriaLabel) {
71+
// eslint-disable-next-line no-console
72+
console.warn('DataViewTh: Missing resizeButtonAriaLabel. An aria label must be passed to each resizable column to provide a context specific label for its resize button.');
73+
}
74+
7075
useEffect(() => {
7176
if (!isResizable) {
7277
return;
@@ -255,7 +260,7 @@ export const DataViewTh: FC<DataViewThProps> = ({
255260
};
256261

257262
return (
258-
<Th {...thProps} {...restProps} style={width > 0 ? { minWidth: width } : undefined} ref={thRef}>
263+
<Th {...thProps} {...props} style={width > 0 ? { minWidth: width } : undefined} ref={thRef}>
259264
{content}
260265
{isResizable && (
261266
<Button

0 commit comments

Comments
 (0)