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
Issue 611 - Hidden columns on copy/paste #621
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1ed5ab3
- hidden columns on copy/paste
fb3fc1a
Merge branch 'dev' into 611-copy-paste-hideable-columns
Marc-Andre-Rivet f8c5919
Merge branch 'dev' into 611-copy-paste-hideable-columns
Marc-Andre-Rivet 92e6a18
Merge branch 'dev' into 611-copy-paste-hideable-columns
Marc-Andre-Rivet 7ce0256
changelog entry
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
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 |
|---|---|---|
|
|
@@ -3,13 +3,75 @@ import * as R from 'ramda'; | |
| import applyClipboardToData from 'dash-table/utils/applyClipboardToData'; | ||
|
|
||
| describe('clipboard', () => { | ||
| const columns = ['c1'].map(id => ({ id: id, name: id, editable: true, sort_as_null: [] })); | ||
|
|
||
| describe('with hidden columns', () => { | ||
| const altColumns = [ | ||
| 'c1', | ||
| 'c2' | ||
| ].map(id => ({ id: id, name: id, editable: true, sort_as_null: [] })); | ||
|
|
||
| describe('with column overflow', () => { | ||
| it('returns all columns, 1st column visible only', () => { | ||
| const altVisibleColumns = altColumns.slice(0, 1); | ||
|
|
||
| const res = applyClipboardToData( | ||
| R.range(0, 2).map(value => [`${value}`, `${value + 1}`]), | ||
| { row: 0, column: 0, column_id: '' }, | ||
| R.range(0, 1), | ||
| altColumns, | ||
| altVisibleColumns, | ||
| R.range(0, 1).map(() => ({ c1: 'c1', c2: 'c2' })), | ||
| true, | ||
| true | ||
| ); | ||
|
|
||
| expect(res).to.not.equal(undefined); | ||
|
|
||
| if (res) { | ||
| expect(res.data.length).to.equal(2); | ||
| expect(Object.entries(res.data[0]).length).to.equal(3); | ||
| expect(res.columns.length).to.equal(3); | ||
| expect(res.columns[0].id).to.equal('c1'); | ||
| expect(res.columns[2].id).to.equal('c2'); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| it('returns all columns, 2nd column visible only', () => { | ||
| const altVisibleColumns = altColumns.slice(-1); | ||
|
|
||
| const res = applyClipboardToData( | ||
| R.range(0, 2).map(value => [`${value}`, `${value + 1}`]), | ||
| { row: 0, column: 0, column_id: '' }, | ||
| R.range(0, 1), | ||
| altColumns, | ||
| altVisibleColumns, | ||
| R.range(0, 1).map(() => ({ c1: 'c1', c2: 'c2' })), | ||
| true, | ||
| true | ||
| ); | ||
|
|
||
| expect(res).to.not.equal(undefined); | ||
|
|
||
| if (res) { | ||
| expect(res.data.length).to.equal(2); | ||
| expect(Object.entries(res.data[0]).length).to.equal(3); | ||
| expect(res.columns.length).to.equal(3); | ||
| expect(res.columns[0].id).to.equal('c1'); | ||
| expect(res.columns[1].id).to.equal('c2'); | ||
|
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. Check that all columns are present and in the right order after a copy/paste operation involving hidden columns |
||
| } | ||
| }); | ||
| }); | ||
|
|
||
| describe('with column/row overflow allowed', () => { | ||
| it('pastes one line at [0, 0] in one line df', () => { | ||
| const res = applyClipboardToData( | ||
| R.range(0, 1).map(value => [`${value}`]), | ||
| {row: 0, column: 0, column_id: ''}, | ||
| { row: 0, column: 0, column_id: '' }, | ||
| R.range(0, 1), | ||
| ['c1'].map(id => ({ id: id, name: id, editable: true, sort_as_null: [] })), | ||
| columns, | ||
| columns, | ||
| R.range(0, 1).map(() => ({ c1: 'c1' })), | ||
| true, | ||
| true | ||
|
|
@@ -26,9 +88,10 @@ describe('clipboard', () => { | |
| it('pastes two lines at [0, 0] in one line df', () => { | ||
| const res = applyClipboardToData( | ||
| R.range(0, 2).map(value => [`${value}`]), | ||
| {row: 0, column: 0, column_id: ''}, | ||
| { row: 0, column: 0, column_id: '' }, | ||
| R.range(0, 1), | ||
| ['c1'].map(id => ({ id: id, name: id, editable: true, sort_as_null: [] })), | ||
| columns, | ||
| columns, | ||
| R.range(0, 1).map(() => ({ c1: 'c1' })), | ||
| true, | ||
| true | ||
|
|
@@ -46,9 +109,10 @@ describe('clipboard', () => { | |
| it('pastes ten lines at [0, 0] in three line df', () => { | ||
| const res = applyClipboardToData( | ||
| R.range(0, 10).map(value => [`${value}`]), | ||
| {row: 0, column: 0, column_id: ''}, | ||
| { row: 0, column: 0, column_id: '' }, | ||
| R.range(0, 3), | ||
| ['c1'].map(id => ({ id: id, name: id, editable: true, sort_as_null: [] })), | ||
| columns, | ||
| columns, | ||
| R.range(0, 3).map(() => ({ c1: 'c1' })), | ||
| true, | ||
| true | ||
|
|
@@ -67,9 +131,10 @@ describe('clipboard', () => { | |
| it('pastes ten lines at [1, 0] in three line df', () => { | ||
| const res = applyClipboardToData( | ||
| R.range(0, 10).map(value => [`${value}`]), | ||
| {row: 1, column: 0, column_id: ''}, | ||
| { row: 1, column: 0, column_id: '' }, | ||
| R.range(0, 3), | ||
| ['c1'].map(id => ({ id: id, name: id, editable: true, sort_as_null: [] })), | ||
| columns, | ||
| columns, | ||
| R.range(0, 3).map(() => ({ c1: 'c1' })), | ||
| true, | ||
| true | ||
|
|
@@ -91,9 +156,10 @@ describe('clipboard', () => { | |
| it('pastes one line at [0, 0] in one line df', () => { | ||
| const res = applyClipboardToData( | ||
| R.range(0, 1).map(value => [`${value}`]), | ||
| {row: 0, column: 0, column_id: ''}, | ||
| { row: 0, column: 0, column_id: '' }, | ||
| R.range(0, 1), | ||
| ['c1'].map(id => ({ id: id, name: id, editable: true, sort_as_null: [] })), | ||
| columns, | ||
| columns, | ||
| R.range(0, 1).map(() => ({ c1: 'c1' })), | ||
| true, | ||
| false | ||
|
|
@@ -110,9 +176,10 @@ describe('clipboard', () => { | |
| it('pastes two lines at [0, 0] in one line df', () => { | ||
| const res = applyClipboardToData( | ||
| R.range(0, 2).map(value => [`${value}`]), | ||
| {row: 0, column: 0, column_id: ''}, | ||
| { row: 0, column: 0, column_id: '' }, | ||
| R.range(0, 1), | ||
| ['c1'].map(id => ({ id: id, name: id, editable: true, sort_as_null: [] })), | ||
| columns, | ||
| columns, | ||
| R.range(0, 1).map(() => ({ c1: 'c1' })), | ||
| true, | ||
| false | ||
|
|
@@ -129,9 +196,10 @@ describe('clipboard', () => { | |
| it('pastes ten lines at [0, 0] in three line df', () => { | ||
| const res = applyClipboardToData( | ||
| R.range(0, 10).map(value => [`${value}`]), | ||
| {row: 0, column: 0, column_id: ''}, | ||
| { row: 0, column: 0, column_id: '' }, | ||
| R.range(0, 3), | ||
| ['c1'].map(id => ({ id: id, name: id, editable: true, sort_as_null: [] })), | ||
| columns, | ||
| columns, | ||
| R.range(0, 3).map(() => ({ c1: 'c1' })), | ||
| true, | ||
| false | ||
|
|
@@ -150,9 +218,10 @@ describe('clipboard', () => { | |
| it('pastes ten lines at [1, 0] in three line df', () => { | ||
| const res = applyClipboardToData( | ||
| R.range(0, 10).map(value => [`${value}`]), | ||
| {row: 1, column: 0, column_id: ''}, | ||
| { row: 1, column: 0, column_id: '' }, | ||
| R.range(0, 3), | ||
| ['c1'].map(id => ({ id: id, name: id, editable: true, sort_as_null: [] })), | ||
| columns, | ||
| columns, | ||
| R.range(0, 3).map(() => ({ c1: 'c1' })), | ||
| true, | ||
| false | ||
|
|
||
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.
When new columns are created, they are appended after the last visible column. Both visible and "all" columns are updated to both (1) handle the copy/paste below and (2) the columns update correctly.
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.
hmm OK - I might have added the new columns after trailing hidden columns as well, but it's probably impossible to declare one way objectively better than the other. This is fine.