diff --git a/.storybook/preview.js b/.storybook/preview.js
index fcdc5705d5..da47f5697c 100644
--- a/.storybook/preview.js
+++ b/.storybook/preview.js
@@ -1,16 +1,25 @@
import '@clayui/css/lib/css/atlas.css';
const spritemap = require('@clayui/css/lib/images/icons/icons.svg');
-import React from 'react';
+import React, {useEffect} from 'react';
+import svg4everybody from 'svg4everybody';
import {Provider} from '@clayui/provider';
export const decorators = [
- (Story) => (
-
-
-
-
-
- ),
+ (Story) => {
+ useEffect(() => {
+ svg4everybody({
+ polyfill: true,
+ });
+ }, []);
+
+ return (
+
+
+
+
+
+ );
+ },
];
export const parameters = {
diff --git a/package.json b/package.json
index 1750b4c674..44e98bf310 100644
--- a/package.json
+++ b/package.json
@@ -103,6 +103,7 @@
"size-limit": "^6.0.3",
"source-map-loader": "^0.2.4",
"style-loader": "^0.23.1",
+ "svg4everybody": "^2.1.9",
"ts-jest": "^28.0.8",
"turbo": "^1.2.6",
"typescript": "4.7.4",
diff --git a/packages/clay-core/src/table/Cell.tsx b/packages/clay-core/src/table/Cell.tsx
index a526c3213a..ab61bdb6bc 100644
--- a/packages/clay-core/src/table/Cell.tsx
+++ b/packages/clay-core/src/table/Cell.tsx
@@ -145,22 +145,50 @@ export const Cell = React.forwardRef(
[expandedKeys, onExpandedChange]
);
+ const doSort = useCallback(
+ () =>
+ onSortChange(
+ {
+ column: keyValue!,
+ direction:
+ sort && keyValue === sort.column
+ ? sort.direction === 'ascending'
+ ? 'descending'
+ : 'ascending'
+ : 'ascending',
+ },
+ textValue!
+ ),
+ [onSortChange, keyValue, sort]
+ );
+
+ const isExpandable = (expandable || lazy) && !isLoading;
+ const isSortable = isHead && sortable;
+
return (
(
: `string,${keyValue}`
}
onClick={(event) => {
- if (!(isHead && sortable)) {
+ if (!isSortable) {
return;
}
event.preventDefault();
- onSortChange(
- {
- column: keyValue!,
- direction:
- sort && keyValue === sort.column
- ? sort.direction === 'ascending'
- ? 'descending'
- : 'ascending'
- : 'ascending',
- },
- textValue!
- );
+ doSort();
}}
onKeyDown={(event) => {
if (event.key === Keys.Enter) {
- toggle(key!);
+ if (isSortable) {
+ event.preventDefault();
+ doSort();
+ }
+
+ if (treegrid && isExpandable) {
+ toggle(key!);
+ }
}
}}
ref={ref}
@@ -208,29 +232,27 @@ export const Cell = React.forwardRef(
style={{
width,
}}
+ tabIndex={focusWithinProps.tabIndex}
>
- {isHead && sortable ? (
- event.preventDefault()}
- role="presentation"
- tabIndex={treegrid ? -1 : undefined}
- >
- {children}
-
- {sort && keyValue === sort.column && (
-
-
+ {isSortable ? (
+
+
+
+
+ {children}
+
- )}
-
+
+
+
+
+
) : truncate ? (
{children}
@@ -243,7 +265,7 @@ export const Cell = React.forwardRef(
(expandable || lazy ? 4 : 0),
}}
>
- {(expandable || lazy) && !isLoading && (
+ {isExpandable && (