Skip to content

Commit

Permalink
chore(@clayui/core): changes the API from sorting to sortable
Browse files Browse the repository at this point in the history
  • Loading branch information
matuzalemsteles committed Sep 22, 2023
1 parent 4a13361 commit 1f2d388
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions packages/clay-core/src/table/Column.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ type Props = {
keyValue?: React.Key;

/**
* Whether the column allows sorting. Only available in the header column.
* Whether the column allows sortable. Only available in the header column.
*/
sorting?: boolean;
sortable?: boolean;

/**
* Aligns horizontally contents inside the Cell.
Expand Down Expand Up @@ -75,7 +75,7 @@ export const Column = React.forwardRef<HTMLTableCellElement, Props>(
delimiter,
expanded,
keyValue,
sorting,
sortable,
textAlign,
textValue,
truncate,
Expand All @@ -86,18 +86,17 @@ export const Column = React.forwardRef<HTMLTableCellElement, Props>(
) {
const {onSortChange, sort, sortDescriptionId} = useTable();
const scope = useScope();
const As = scope === Scope.Head ? 'th' : 'td';
const isHead = scope === Scope.Head;
const As = isHead ? 'th' : 'td';

return (
<As
{...otherProps}
aria-describedby={
scope === Scope.Head && sorting
? sortDescriptionId
: undefined
isHead && sortable ? sortDescriptionId : undefined
}
aria-sort={
scope === Scope.Head && sorting
isHead && sortable
? sort && keyValue === sort.column
? sort.direction
: 'none'
Expand All @@ -109,16 +108,14 @@ export const Column = React.forwardRef<HTMLTableCellElement, Props>(
[`table-column-text-${textAlign}`]: textAlign,
[`text-${align}`]: align,
'table-cell-ws-nowrap': !wrap,
'table-head-title': scope === Scope.Head,
'table-head-title': isHead,
})}
ref={ref}
>
{scope === Scope.Head && sorting ? (
{isHead && sortable ? (
<a
aria-describedby={
scope === Scope.Head && sorting
? sortDescriptionId
: undefined
isHead && sortable ? sortDescriptionId : undefined
}
className="inline-item text-truncate-inline"
href="#"
Expand Down

0 comments on commit 1f2d388

Please sign in to comment.