Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,11 @@
Issue: https://github.com/plotly/dash-table/issues/68
Issue: https://github.com/plotly/dash-table/issues/73
Issue: https://github.com/plotly/dash-table/issues/76

## RC13 - Modify click & sequential click behavior

Incremental improvement for:
Issue: https://github.com/plotly/dash-table/issues/77

First click selects the cell's content and will cause user input to override the cell content.
Second click into the cell will remove the selection and position the cursor accordingly.
6 changes: 3 additions & 3 deletions dash_table/bundle.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dash_table/demo.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dash_table/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-table",
"version": "3.0.0rc12",
"version": "3.0.0rc13",
"description": "Dash table",
"main": "build/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-table",
"version": "3.0.0rc12",
"version": "3.0.0rc13",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump version

"description": "Dash table",
"main": "build/index.js",
"scripts": {
Expand Down
6 changes: 4 additions & 2 deletions src/dash-table/components/Cell/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,11 @@ export default class Cell extends Component<ICellProps, ICellState> {

componentDidUpdate() {
const { active } = this.propsWithDefaults;
const input = this.refs.textInput as HTMLInputElement;

if (active && this.refs.textInput) {
(this.refs.textInput as HTMLElement).focus();
if (active && input && document.activeElement !== input) {
input.focus();
input.setSelectionRange(0, input.value ? input.value.length : 0);
}

if (active && this.refs.dropdown) {
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/cypress/integration/copy_paste_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('copy paste', () => {

it('can do BE roundtrip on cell modification', () => {
DashTable.getCell(0, 0).click();
DOM.focused.type(`1${Key.Enter}`);
DOM.focused.type(`10${Key.Enter}`);

DashTable
.getCell(0, 0)
Expand Down
16 changes: 14 additions & 2 deletions tests/e2e/cypress/integration/dash_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ describe('dash basic', () => {
DashTable.getCell(0, 2).within(() => cy.get('input').should('have.value', '250'));
});

it('cell click selects all text', () => {
DashTable.getCell(0, 3).click();
DashTable.getCell(0, 3).within(() =>
cy.get('input').then($inputs => {
const $input = $inputs[0];

expect($input.selectionStart).to.equal(0);
expect($input.selectionEnd).to.equal($input.value.length);
})
);
});

// https://github.com/plotly/dash-table/issues/50
it('can edit last and update dataframe on "enter"', () => {
DashTable.getCell(249, 2).click();
Expand All @@ -24,7 +36,7 @@ describe('dash basic', () => {
DOM.focused.type(`abc${Key.Enter}`);

cy.get('#container').should($container => {
expect($container.first()[0].innerText).to.equal(`[249][0] = ${initialValue} -> abc${initialValue}`);
expect($container.first()[0].innerText).to.equal(`[249][0] = ${initialValue} -> abc`);
});
});
});
Expand All @@ -38,7 +50,7 @@ describe('dash basic', () => {
DashTable.getCell(248, 2).click();

cy.get('#container').should($container => {
expect($container.first()[0].innerText).to.equal(`[249][0] = ${initialValue} -> abc${initialValue}`);
expect($container.first()[0].innerText).to.equal(`[249][0] = ${initialValue} -> abc`);
});
});
});
Expand Down
18 changes: 5 additions & 13 deletions tests/e2e/cypress/integration/edit_cell_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,14 @@ describe('edit cell', () => {
// https://github.com/plotly/dash-table/issues/50
it('can edit on "enter"', () => {
DashTable.getCell(0, 3).click();
DOM.focused.then($input => {
const initialValue = $input.val();

DOM.focused.type(`abc${Key.Enter}`);
DashTable.getCell(0, 3).within(() => cy.get('.cell-value').should('have.html', `abc${initialValue}`));
});
DOM.focused.type(`abc${Key.Enter}`);
DashTable.getCell(0, 3).within(() => cy.get('.cell-value').should('have.html', `abc`));
});

it('can edit when clicking outside of cell', () => {
DashTable.getCell(0, 3).click();
DOM.focused.then($input => {
const initialValue = $input.val();

DOM.focused.type(`abc`);
DashTable.getCell(0, 2).click();
DashTable.getCell(0, 3).within(() => cy.get('.cell-value').should('have.html', `abc${initialValue}`));
});
DOM.focused.type(`abc`);
DashTable.getCell(0, 2).click();
DashTable.getCell(0, 3).within(() => cy.get('.cell-value').should('have.html', `abc`));
});
});