Skip to content

Commit

Permalink
Merge pull request #1440 from dhis2/LIBS-539/data-row-props
Browse files Browse the repository at this point in the history
feat(LIBS-539): forward data-table-row props to allow handling dom events
  • Loading branch information
kabaros authored Dec 21, 2023
2 parents 4643200 + a293b16 commit 98b734e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions components/table/src/data-table/__tests__/data-table-row.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,23 @@ describe('<DataTableRow>', () => {
expect(cb).toHaveBeenCalledTimes(1)
expect(cb).toHaveBeenCalledWith({ expanded: true })
})

it('accepts a hover prop', () => {
const cb = jest.fn()
const wrapper = mount(
<DataTableRow
expandable
expandableContent="test"
onExpandToggle={cb}
onMouseOver={cb}
onClick={cb}
/>
)

wrapper.find('tr').simulate('mouseover')

wrapper.find('tr').simulate('click')

expect(cb).toHaveBeenCalledTimes(2)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export const DataTableRow = forwardRef(
draggable,
role,
onExpandToggle,
...rest
},
ref
) => {
Expand All @@ -45,6 +46,7 @@ export const DataTableRow = forwardRef(
selected={selected}
draggable={draggable}
role={role}
{...rest}
>
{draggable && <DragHandleCell />}
{expandableContent && (
Expand Down
2 changes: 2 additions & 0 deletions components/table/src/table/table-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const TableRow = ({
className,
dataTest,
suppressZebraStriping,
...rest
}) => {
const { suppressZebraStriping: suppressZebraStripingFromContext } =
useContext(TableContext)
Expand All @@ -30,6 +31,7 @@ export const TableRow = ({
className={cx(className, { zebraStriping })}
data-test={dataTest}
role={role}
{...rest}
>
{children}

Expand Down

0 comments on commit 98b734e

Please sign in to comment.