Skip to content

Commit 7ab7b14

Browse files
author
Amrit Borah
committed
feat: if onRowCilck provided handle enter press internally
1 parent 460b941 commit 7ab7b14

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

src/Shared/Components/Table/TableContent.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,24 @@ const TableContent = <
235235
}
236236
}, [isAnyRowExpandable])
237237

238+
useEffect(() => {
239+
if (!onRowClick) {
240+
return () => {}
241+
}
242+
243+
const handleEnterPress = ({ detail: { activeRowData } }) => {
244+
onRowClick(activeRowData, activeRowData.id.startsWith('expanded-row-' satisfies ExpandedRowPrefixType))
245+
}
246+
247+
const signals = EVENT_TARGET as SignalsType
248+
249+
signals.addEventListener(SignalEnum.ENTER_PRESSED, handleEnterPress)
250+
251+
return () => {
252+
signals.removeEventListener(SignalEnum.ENTER_PRESSED, handleEnterPress)
253+
}
254+
}, [onRowClick])
255+
238256
const toggleExpandAll = (e: MouseEvent<HTMLButtonElement>) => {
239257
e.stopPropagation()
240258

src/Shared/Components/Table/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ export type TableProps<
423423
| 'clearFilters'
424424
| 'rowStartIconConfig'
425425
| 'onRowClick'
426+
| 'areFiltersApplied'
426427
>
427428

428429
export type BulkActionStateType = string | null

0 commit comments

Comments
 (0)