Przeglądaj źródła

Explore: fix copy/paste on table cells

When selecting text via mouse, our ReactTable cells' click handler
triggers an event.

- check event target to be the link, only then handle the event
David Kaltschmidt 7 lat temu
rodzic
commit
5a23723f2c
1 zmienionych plików z 10 dodań i 4 usunięć
  1. 10 4
      public/app/features/explore/Table.tsx

+ 10 - 4
public/app/features/explore/Table.tsx

@@ -21,10 +21,16 @@ function prepareRows(rows, columnNames) {
 export default class Table extends PureComponent<TableProps> {
   getCellProps = (state, rowInfo, column) => {
     return {
-      onClick: () => {
-        const columnKey = column.Header;
-        const rowValue = rowInfo.row[columnKey];
-        this.props.onClickCell(columnKey, rowValue);
+      onClick: (e: React.SyntheticEvent) => {
+        // Only handle click on link, not the cell
+        if (e.target) {
+          const link = e.target as HTMLElement;
+          if (link.className === 'link') {
+            const columnKey = column.Header;
+            const rowValue = rowInfo.row[columnKey];
+            this.props.onClickCell(columnKey, rowValue);
+          }
+        }
       },
     };
   };