Skip to content

Commit

Permalink
fix keyboard navigation after copy/paste (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc-Andre-Rivet committed Sep 14, 2018
1 parent 693ff5a commit bebde86
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 15 deletions.
6 changes: 5 additions & 1 deletion packages/dash-table/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,8 @@
## RC15 - Global copy/paste (through browser menu), incorrect pasted data fix

Issue: https://github.com/plotly/dash-table/issues/75
Issue: https://github.com/plotly/dash-table/issues/88
Issue: https://github.com/plotly/dash-table/issues/88

## RC16 - Fix incorrect keyboard navigation

Issue: https://github.com/plotly/dash-table/issues/49
6 changes: 3 additions & 3 deletions packages/dash-table/dash_table/bundle.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions packages/dash-table/dash_table/demo.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/dash-table/dash_table/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-table",
"version": "3.0.0rc15",
"version": "3.0.0rc16",
"description": "Dash table",
"main": "build/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/dash-table/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-table",
"version": "3.0.0rc15",
"version": "3.0.0rc16",
"description": "Dash table",
"main": "build/index.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import { colIsEditable } from 'dash-table/components/derivedState';
import {
KEY_CODES,
isCtrlMetaKey,
/*#if TEST_COPY_PASTE*/
isCtrlDown,
/*#endif*/
isMetaKey,
isNavKey
} from 'dash-table/utils/unicode';
Expand Down Expand Up @@ -137,20 +135,23 @@ export default class ControlledTable extends Component<ControlledTableProps> {
return;
}

/*#if TEST_COPY_PASTE*/
const ctrlDown = isCtrlDown(e);

if (ctrlDown && e.keyCode === KEY_CODES.V) {
/*#if TEST_COPY_PASTE*/
this.onPaste({} as any);
e.preventDefault();
/*#endif*/
return;
}

if (e.keyCode === KEY_CODES.C && ctrlDown && !is_focused) {
/*#if TEST_COPY_PASTE*/
this.onCopy(e as any);
e.preventDefault();
/*#endif*/
return;
}
/*#endif*/

if (e.keyCode === KEY_CODES.ESCAPE) {
setProps({ is_focused: false });
Expand Down Expand Up @@ -452,8 +453,6 @@ export default class ControlledTable extends Component<ControlledTableProps> {
} = this.props;
const dataframe = virtualizer.dataframe;

e.preventDefault();

const columnIndexOffset =
(row_deletable ? 1 : 0) +
(row_selectable ? 1 : 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ describe('navigate', () => {
});
});

// Issue: https://github.com/plotly/dash-table/issues/49
it.only('can move after ctrl+c', () => {
DOM.focused.type(`${Key.Meta}c`);
DOM.focused.type(Key.ArrowDown);
DashTable.getCell(4, 3).should('have.class', 'focused');
DashTable.getCell(3, 3).should('not.have.class', 'focused');
});

it('can move down', () => {
DOM.focused.type(Key.ArrowDown);
DashTable.getCell(4, 3).should('have.class', 'focused');
Expand Down

0 comments on commit bebde86

Please sign in to comment.