Skip to content

Commit c5cc994

Browse files
Issue 206 - Filter copy/paste (#623)
1 parent 8da5f7f commit c5cc994

File tree

4 files changed

+22
-0
lines changed

4 files changed

+22
-0
lines changed

Diff for: packages/dash-table/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ This project adheres to [Semantic Versioning](http://semver.org/).
88
- [#618](https://github.com/plotly/dash-table/issues/618) Fix a bug with keyboard navigation not
99
working correctly in certain circumstances when the table contains `readonly` columns.
1010

11+
- [#206](https://github.com/plotly/dash-table/issues/206) Fix a bug with copy/paste to and from
12+
column filters not working.
13+
1114
## [4.4.0] - 2019-10-08
1215
### Added
1316
[#546](https://github.com/plotly/dash-table/issues/546)

Diff for: packages/dash-table/src/core/components/IsolatedInput/index.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { KEY_CODES } from 'dash-table/utils/unicode';
44
type Submit = (value: string | undefined) => void;
55

66
interface IProps {
7+
onCopy?: (e: any) => void;
8+
onPaste?: (e: any) => void;
79
placeholder?: string;
810
updateOnBlur?: boolean;
911
updateOnSubmit?: boolean;
@@ -84,6 +86,8 @@ export default class IsolatedInput extends PureComponent<IProps, IState> {
8486

8587
render() {
8688
const {
89+
onCopy,
90+
onPaste,
8791
placeholder,
8892
updateOnBlur,
8993
updateOnSubmit
@@ -100,6 +104,8 @@ export default class IsolatedInput extends PureComponent<IProps, IState> {
100104
type='text'
101105
value={this.state.value || ''}
102106
onChange={this.handleChange}
107+
onCopy={onCopy}
108+
onPaste={onPaste}
103109
placeholder={placeholder}
104110
{...props}
105111
/>);

Diff for: packages/dash-table/src/dash-table/components/Filter/Column.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React, { CSSProperties, PureComponent } from 'react';
33
import IsolatedInput from 'core/components/IsolatedInput';
44

55
import { ColumnId } from 'dash-table/components/Table/props';
6+
import TableClipboardHelper from 'dash-table/utils/TableClipboardHelper';
67

78
type SetFilter = (ev: any) => void;
89

@@ -51,6 +52,13 @@ export default class ColumnFilter extends PureComponent<IColumnFilterProps, ISta
5152
style={style}
5253
>
5354
<IsolatedInput
55+
onCopy={(e: any) => {
56+
e.stopPropagation();
57+
TableClipboardHelper.clearClipboard();
58+
}}
59+
onPaste={(e: any) => {
60+
e.stopPropagation();
61+
}}
5462
value={value}
5563
placeholder={`filter data...`}
5664
stopPropagation={true}

Diff for: packages/dash-table/src/dash-table/utils/TableClipboardHelper.ts

+5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ export default class TableClipboardHelper {
4242
Clipboard.set(e, value);
4343
}
4444

45+
public static clearClipboard() {
46+
TableClipboardHelper.lastLocalCopy = [];
47+
TableClipboardHelper.localCopyWithoutHeaders = [];
48+
}
49+
4550
public static fromClipboard(
4651
ev: ClipboardEvent,
4752
activeCell: ICellCoordinates,

0 commit comments

Comments
 (0)