Skip to content

Commit

Permalink
fix(tables): stop click event propagation in RowCheckbox
Browse files Browse the repository at this point in the history
  • Loading branch information
ivangabriele committed Mar 15, 2024
1 parent 472e11f commit 7e218ec
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions config/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default {
baseUrl: './src',
paths: {
'@elements/*': ['elements/*'],
'@fields/*': ['fields/*'],
'@hooks/*': ['hooks/*'],
'@libs/*': ['libs/*'],
'@types_/*': ['types/*'],
Expand Down
3 changes: 2 additions & 1 deletion src/tables/TableWithSelectableRows/RowCheckbox.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { stopMouseEventPropagation } from '@utils/stopMouseEventPropagation'
import { type HTMLProps } from 'react'
import { Checkbox as RsuiteCheckbox } from 'rsuite'

Expand All @@ -9,7 +10,6 @@ export type RowCheckboxProps = {
isIndeterminate?: boolean
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void
}

export function RowCheckbox({
className = '',
disabled = false,
Expand All @@ -25,6 +25,7 @@ export function RowCheckbox({
indeterminate={isIndeterminate}
// eslint-disable-next-line @typescript-eslint/naming-convention
onChange={(_, __, event) => onChange(event)}
onClick={stopMouseEventPropagation}
/>
)
}
2 changes: 1 addition & 1 deletion src/utils/stopMouseEventPropagation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { MouseEvent } from 'react'

export function stopMouseEventPropagation(event: MouseEvent<HTMLElement>) {
export function stopMouseEventPropagation(event: MouseEvent<HTMLElement> | React.SyntheticEvent<Element, Event>) {
event.stopPropagation()
}
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"outDir": "./dist",
"paths": {
"@elements/*": ["elements/*"],
"@fields/*": ["fields/*"],
"@hooks/*": ["hooks/*"],
"@libs/*": ["libs/*"],
"@types_/*": ["types/*"],
Expand Down

0 comments on commit 7e218ec

Please sign in to comment.