Skip to content

Commit 557efcd

Browse files
authored
Remove Nested <a> Tag and fix Actions missing Key warning (#46)
1 parent 691709c commit 557efcd

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
# Changed
11+
12+
- :boom: `view` default Action does not nest an `<a>` tag anymore.
13+
1014
## [2.7.3] - 2023-06-29
1115

1216
### Changed

src/lib/DataTable/Actions/ActionsCell.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { faPlus, faMinus, faEye } from "@fortawesome/free-solid-svg-icons";
22
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
33
import { DeleteAction } from "@neolution-ch/react-pattern-ui";
44
import { DataTableRoutedActions } from "../DataTableInterfaces";
5+
import React from "react";
56

67
interface ActionsCellProps<T, TRouteName> {
78
actions?: DataTableRoutedActions<T, TRouteName>;
@@ -24,9 +25,7 @@ const ActionsCell = <T, TRouteName>({ actions, collapsed, setCollapsed, keyValue
2425
)}
2526
{actions.view && (
2627
<actions.view.link route={actions.view.route} params={actions.view.getParams({ keyValue, cell: record })}>
27-
<a>
28-
<FontAwesomeIcon icon={actions.view.icon ?? faEye} style={{ marginRight: "5px" }} />
29-
</a>
28+
<FontAwesomeIcon icon={actions.view.icon ?? faEye} style={{ marginRight: "5px" }} />
3029
</actions.view.link>
3130
)}
3231
{actions.delete && (
@@ -37,7 +36,10 @@ const ActionsCell = <T, TRouteName>({ actions, collapsed, setCollapsed, keyValue
3736
onDelete={() => actions?.delete?.action({ key: keyValue, cell: record })}
3837
/>
3938
)}
40-
{actions.others && actions.others.map((action) => action.formatter({ key: keyValue, row: record }))}
39+
{actions.others &&
40+
actions.others.map((action, idx) => (
41+
<React.Fragment key={idx}>{action.formatter({ key: keyValue, row: record })}</React.Fragment>
42+
))}
4143
</th>
4244
)}
4345
</>

0 commit comments

Comments
 (0)