This repository was archived by the owner on Aug 29, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 72
fix dropdown regression + test #78
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
| } | ||
|
|
@@ -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 | ||
|
|
@@ -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; | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
| }); | ||
| }); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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