Skip to content

Commit

Permalink
select on row click (#1531)
Browse files Browse the repository at this point in the history
  • Loading branch information
hassanad94 authored Sep 29, 2023
1 parent cdd6373 commit 0f91ffc
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function TreePicker<T extends GenericContentWithIsParent = GenericContent
})

const onCheckedChangeHandler = useCallback(
(_event: React.ChangeEvent<HTMLInputElement>, node: T) => {
(_event: unknown, node: T) => {
if (!node.isParent) {
const newSelection = props.allowMultiple ? selection.filter((item) => item.Id !== node.Id) : []
if (newSelection.length === selection.length || (!props.allowMultiple && selection[0].Id !== node.Id)) {
Expand Down Expand Up @@ -106,7 +106,10 @@ export function TreePicker<T extends GenericContentWithIsParent = GenericContent
return (
<List>
{items?.map((item) => (
<div onDoubleClick={(e) => onDoubleClickHandler(e, item as any)} key={item.Id}>
<div
onClick={(e) => onCheckedChangeHandler(e, item as any)}
onDoubleClick={(e) => onDoubleClickHandler(e, item as any)}
key={item.Id}>
{renderItem(item as any)}
</div>
))}
Expand Down

0 comments on commit 0f91ffc

Please sign in to comment.