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: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,10 @@

Issue: https://github.com/plotly/dash-table/issues/64
Issue: https://github.com/plotly/dash-table/issues/65
Issue: https://github.com/plotly/dash-table/issues/67
Issue: https://github.com/plotly/dash-table/issues/67

## RC12 - Dropdown regression fix, border style fix, zoom/resize fix

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
2 changes: 1 addition & 1 deletion dash_table/bundle.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 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.0rc11",
"version": "3.0.0rc12",
"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.0rc11",
"version": "3.0.0rc12",
"description": "Dash table",
"main": "build/index.js",
"scripts": {
Expand Down
6 changes: 1 addition & 5 deletions src/dash-table/components/Cell/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,7 @@ export default class Cell extends Component<ICellProps, ICellState> {

const { onChange } = this.props;

onChange({
target: {
value: this.state.value
}
} as any);
onChange(this.state.value);
}

handleChange = (e: any) => {
Expand Down
4 changes: 2 additions & 2 deletions src/dash-table/components/CellFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default class CellFactory {
}
}

private handleChange = (idx: number, i: number, e: any) => {
private handleChange = (idx: number, i: number, value: any) => {

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.

Doing away with the event wrapper, it served no purpose at this point

const {
columns,
dataframe,
Expand All @@ -144,7 +144,7 @@ export default class CellFactory {

const newDataframe = R.set(
R.lensPath([idx, c.id]),
e.target.value,
value,
dataframe
);
setProps({
Expand Down
42 changes: 24 additions & 18 deletions src/dash-table/components/ControlledTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ export default class ControlledTable extends Component<ControlledTableProps> {

// Fallback method for paste handling in Chrome
// when no input element has focused inside the table
window.addEventListener('resize', this.handleResize);

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.

Zoom triggers a resize event, so does resizing the window/browser.. but that's the best we have access to.

document.addEventListener('paste', this.handlePaste);
document.addEventListener('mousedown', this.handleClickOutside);
}

componentWillUnmount() {
window.removeEventListener('resize', this.handleResize);
document.removeEventListener('mousedown', this.handleClickOutside);
document.removeEventListener('paste', this.handlePaste);
}
Expand All @@ -63,6 +65,28 @@ export default class ControlledTable extends Component<ControlledTableProps> {
}

componentDidUpdate() {
this.handleResize();
}

handleClickOutside = (event: any) => {
const $el = this.$el;

if ($el && !$el.contains(event.target as Node)) {
this.props.setProps({ is_focused: false });
}
}

handlePaste = (event: any) => {
// no need to check for target as this will only be called if
// a child fails to handle the paste event (e.g table, table input)
// make sure the active element is in the scope of the component
const $el = this.$el;
if ($el && $el.contains(document.activeElement)) {
this.onPaste(event);
}
}

handleResize = () => {
const { r0c0, r0c1, r1c0, r1c1 } = this.refs as { [key: string]: HTMLElement };

// Adjust [fixed columns/fixed rows combo] to fixed rows height
Expand Down Expand Up @@ -91,24 +115,6 @@ export default class ControlledTable extends Component<ControlledTableProps> {
}
}

handleClickOutside = (event: any) => {
const $el = this.$el;

if ($el && !$el.contains(event.target as Node)) {
this.props.setProps({ is_focused: false });
}
}

handlePaste = (event: any) => {
// no need to check for target as this will only be called if
// a child fails to handle the paste event (e.g table, table input)
// make sure the active element is in the scope of the component
const $el = this.$el;
if ($el && $el.contains(document.activeElement)) {
this.onPaste(event);
}
}

get $el() {
return document.getElementById(this.props.id) as HTMLElement;
}
Expand Down
2 changes: 1 addition & 1 deletion src/dash-table/components/Table/Table.less
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
}

&.focused + td {
.inset-shadow(var(--border), 0px, 0px, 0px, -1px);
.inset-shadow(var(--border), 0px, 0px, -1px, -1px);
}
}
}
Expand Down
30 changes: 30 additions & 0 deletions tests/e2e/cypress/integration/edit_cell_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,36 @@ describe('edit cell', () => {
cy.visit('http://localhost:8080');
});

it('can edit dropdown', () => {
let initialValue: string;
let expectedValue: string;

DashTable.getCell(0, 8).within(() => {
cy.get('.Select-value-label').then($valueLabel => {
initialValue = $valueLabel[0].innerHTML;
cy.log('initial value', initialValue);
});
});

DashTable.getCell(0, 8).within(() => cy.get('div.Select').click()).then(() => {
DashTable.getCell(0, 8).within(() => {
cy.get('.Select-option').then($options => {
const target = Array.from($options).find($option => $option.innerHTML !== initialValue);
if (target) {
cy.wrap(target).click({ force: true });

expectedValue = target.innerHTML;
cy.log('expected value', expectedValue);
}
});
});
});

DashTable.getCell(0, 8).within(() => {
cy.get('.Select-value-label').should('have.html', expectedValue);
});
});

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.

Click on a cell with dropdown, check current value, select a different value, make sure it's applied.


// https://github.com/plotly/dash-table/issues/50
it('can edit on "enter"', () => {
DashTable.getCell(0, 3).click();
Expand Down