| @@ -209,7 +209,24 @@ function SearchResults<T extends ResultWithId>({ | |||||
| }; | }; | ||||
| // checkbox | // checkbox | ||||
| const handleRowClick = useCallback((event: MouseEvent<unknown>, id: string | number) => { | |||||
| const handleRowClick = useCallback((event: MouseEvent<unknown>, item: T, columns: Column<T>[]) => { | |||||
| // check is disabled or not | |||||
| var disabled = false | |||||
| columns.forEach((col) => { | |||||
| if (isCheckboxColumn(col) && col.disabled) { | |||||
| disabled = col.disabled(item) | |||||
| if (disabled) { | |||||
| return; | |||||
| } | |||||
| } | |||||
| }) | |||||
| if (disabled) { | |||||
| return; | |||||
| } | |||||
| // set id | |||||
| const id = item.id | |||||
| if (setCheckboxIds) { | if (setCheckboxIds) { | ||||
| const selectedIndex = checkboxIds.indexOf(id); | const selectedIndex = checkboxIds.indexOf(id); | ||||
| let newSelected: (string | number)[] = []; | let newSelected: (string | number)[] = []; | ||||
| @@ -257,7 +274,7 @@ function SearchResults<T extends ResultWithId>({ | |||||
| hover | hover | ||||
| tabIndex={-1} | tabIndex={-1} | ||||
| key={item.id} | key={item.id} | ||||
| onClick={setCheckboxIds ? (event) => handleRowClick(event, item.id) : undefined} | |||||
| onClick={setCheckboxIds? (event) => handleRowClick(event, item, columns) : undefined} | |||||
| role={setCheckboxIds ? "checkbox" : undefined} | role={setCheckboxIds ? "checkbox" : undefined} | ||||
| > | > | ||||
| {columns.map((column, idx) => { | {columns.map((column, idx) => { | ||||