Skip to content

Commit

Permalink
Add onChange event handler to TableSelectRow (#7293)
Browse files Browse the repository at this point in the history
* Add onChange event handler to TableSelectRow

It allows to pass a function to the TableSelectRow when the row was selected. Only tested it with the radio button version.

* feat(TableSelectRow): add onChange prop-type

* chore(tests): update snapshots

* fix(data-table): small tweak

Co-authored-by: TJ Egan <tw15egan@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people committed Nov 30, 2020
1 parent 3c3049f commit d804515
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Expand Up @@ -1250,6 +1250,9 @@ Map {
"isRequired": true,
"type": "string",
},
"onChange": Object {
"type": "func",
},
"onSelect": Object {
"isRequired": true,
"type": "func",
Expand Down Expand Up @@ -1870,6 +1873,9 @@ Map {
"isRequired": true,
"type": "string",
},
"onChange": Object {
"type": "func",
},
"onSelect": Object {
"isRequired": true,
"type": "func",
Expand Down
7 changes: 7 additions & 0 deletions packages/react/src/components/DataTable/TableSelectRow.js
Expand Up @@ -19,6 +19,7 @@ const TableSelectRow = ({
id,
name,
onSelect,
onChange,
disabled,
radio,
className,
Expand All @@ -27,6 +28,7 @@ const TableSelectRow = ({
id,
name,
onClick: onSelect,
onChange,
checked,
disabled,
};
Expand Down Expand Up @@ -79,6 +81,11 @@ TableSelectRow.propTypes = {
*/
name: PropTypes.string.isRequired,

/**
* Provide an optional hook that is called each time the input is updated
*/
onChange: PropTypes.func,

/**
* Provide a handler to listen to when a user initiates a selection request
*/
Expand Down

0 comments on commit d804515

Please sign in to comment.