X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/5c513f2c78337482da4cc6055706fd022c26c007..e8d0331277033fea37a9fd73ffc781ffca8759f0:/src/components/data-table/data-table.tsx

diff --git a/src/components/data-table/data-table.tsx b/src/components/data-table/data-table.tsx
index 5372128f31..854b322052 100644
--- a/src/components/data-table/data-table.tsx
+++ b/src/components/data-table/data-table.tsx
@@ -15,7 +15,7 @@ export interface DataTableProps<T> {
     items: T[];
     columns: DataColumns<T>;
     onRowClick: (event: React.MouseEvent<HTMLTableRowElement>, item: T) => void;
-    onRowContextMenu: (event: React.MouseEvent<HTMLTableRowElement>, item: T) => void;
+    onContextMenu: (event: React.MouseEvent<HTMLElement>, item: T) => void;
     onSortToggle: (column: DataColumn<T>) => void;
     onFiltersChange: (filters: DataTableFilterItem[], column: DataColumn<T>) => void;
 }
@@ -23,7 +23,8 @@ export interface DataTableProps<T> {
 class DataTable<T extends DataItem> extends React.Component<DataTableProps<T> & WithStyles<CssRules>> {
     render() {
         const { items, classes } = this.props;
-        return <div className={classes.tableContainer}>
+        return <div
+            className={classes.tableContainer}>
             <Table>
                 <TableHead>
                     <TableRow>
@@ -40,7 +41,7 @@ class DataTable<T extends DataItem> extends React.Component<DataTableProps<T> &
     renderHeadCell = (column: DataColumn<T>, index: number) => {
         const { name, key, renderHeader, filters, sortDirection } = column;
         const { onSortToggle, onFiltersChange } = this.props;
-        return <TableCell key={key || index} style={{width: column.width, minWidth: column.width}}>
+        return <TableCell key={key || index} style={{ width: column.width, minWidth: column.width }}>
             {renderHeader ?
                 renderHeader() :
                 filters
@@ -68,12 +69,12 @@ class DataTable<T extends DataItem> extends React.Component<DataTableProps<T> &
     }
 
     renderBodyRow = (item: T, index: number) => {
-        const { onRowClick, onRowContextMenu } = this.props;
+        const { onRowClick, onContextMenu } = this.props;
         return <TableRow
             hover
             key={item.key}
             onClick={event => onRowClick && onRowClick(event, item)}
-            onContextMenu={event => onRowContextMenu && onRowContextMenu(event, item)}>
+            onContextMenu={this.handleRowContextMenu(item)}>
             {this.mapVisibleColumns((column, index) => (
                 <TableCell key={column.key || index}>
                     {column.render(item)}
@@ -86,6 +87,10 @@ class DataTable<T extends DataItem> extends React.Component<DataTableProps<T> &
         return this.props.columns.filter(column => column.selected).map(fn);
     }
 
+    handleRowContextMenu = (item: T) =>
+        (event: React.MouseEvent<HTMLElement>) =>
+            this.props.onContextMenu(event, item)
+
 }
 
 type CssRules = "tableBody" | "tableContainer" | "noItemsInfo";
