Skip to content

Commit 0164c19

Browse files
authored
fix: Selected text in info panel cannot be copied using Ctrl+C (#2951)
1 parent 52eada7 commit 0164c19

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/components/AggregationPanel/AggregationPanel.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,23 @@ const AggregationPanel = ({
190190
);
191191
}
192192

193+
const handleKeyDown = (e) => {
194+
if ((e.ctrlKey || e.metaKey) && e.key === 'c') {
195+
const selection = window.getSelection();
196+
if (selection && selection.toString().length > 0) {
197+
// Stop the event from propagating to parent handlers
198+
e.stopPropagation();
199+
// Let the default copy behavior happen by not calling preventDefault
200+
return;
201+
}
202+
}
203+
};
204+
193205
return (
194-
<div className={styles.aggregationPanel}>
206+
<div
207+
onKeyDown={handleKeyDown}
208+
tabIndex={0}
209+
>
195210
{isLoadingInfoPanel ? (
196211
<div className={styles.center}>
197212
<LoaderDots />

src/dashboard/Data/Browser/DataBrowser.react.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,21 @@ export default class DataBrowser extends React.Component {
379379
return;
380380
}
381381
if (e.keyCode === 67 && (e.ctrlKey || e.metaKey)) {
382+
// Check for text selection FIRST
383+
const selection = window.getSelection();
384+
const selectedText = selection ? selection.toString() : '';
385+
386+
// If there's text selected, check if we're in the aggregation panel
387+
if (selectedText.length > 0) {
388+
const target = e.target;
389+
const isWithinPanel = this.aggregationPanelRef?.current && this.aggregationPanelRef.current.contains(target);
390+
391+
if (isWithinPanel) {
392+
// Let the browser handle the copy operation for selected text
393+
return;
394+
}
395+
}
396+
382397
// check if there is multiple selected cells
383398
const { rowStart, rowEnd, colStart, colEnd } = this.state.selectedCells;
384399
if (rowStart !== -1 && rowEnd !== -1 && colStart !== -1 && colEnd !== -1) {

0 commit comments

Comments
 (0)