jenkins-bot has submitted this change and it was merged.

Change subject: Ensure data isn't discarded when moving a row next to sparse 
cells
......................................................................


Ensure data isn't discarded when moving a row next to sparse cells

Bug: T142879
Change-Id: Ib243825fe33704a07639b4289d7f4ceff052f7d7
---
M src/ui/actions/ve.ui.TableAction.js
M tests/ui/actions/ve.ui.TableAction.test.js
2 files changed, 21 insertions(+), 1 deletion(-)

Approvals:
  Jforrester: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/ui/actions/ve.ui.TableAction.js 
b/src/ui/actions/ve.ui.TableAction.js
index 4573b14..0e76683 100644
--- a/src/ui/actions/ve.ui.TableAction.js
+++ b/src/ui/actions/ve.ui.TableAction.js
@@ -581,9 +581,10 @@
                refCells = matrix.getColumn( refIndex ) || [];
        }
 
-       for ( i = 0, l = cells.length; i < l; i++ ) {
+       for ( i = 0, l = Math.max( cells.length, dataMatrixLine ? 
dataMatrixLine.cells.length : 0 ); i < l; i++ ) {
                cell = cells[ i ];
                if ( !cell ) {
+                       insertCells.push( dataMatrixLine.cells[ i ] );
                        continue;
                }
                refCell = refCells[ i ];
diff --git a/tests/ui/actions/ve.ui.TableAction.test.js 
b/tests/ui/actions/ve.ui.TableAction.test.js
index e1f0c57..191c487 100644
--- a/tests/ui/actions/ve.ui.TableAction.test.js
+++ b/tests/ui/actions/ve.ui.TableAction.test.js
@@ -420,6 +420,25 @@
                                        data[ 40 ].attributes.style = 'header';
                                },
                                msg: 'change style to header'
+                       },
+                       // TODO: Write tests for simple row/column moves
+                       {
+                               html: 
'<table><tr></tr><tr><td>A</td></tr></table>',
+                               rangeOrSelection: {
+                                       type: 'table',
+                                       tableRange: new ve.Range( 0, 13 ),
+                                       fromCol: 0,
+                                       fromRow: 1,
+                                       toCol: 0,
+                                       toRow: 1
+                               },
+                               method: 'moveRelative',
+                               args: [ 'row', 'before' ],
+                               expectedData: function ( data ) {
+                                       var row = data.splice( 4, 7 );
+                                       data.splice.apply( data, [ 2, 0 
].concat( row ) );
+                               },
+                               msg: 'move row adjacent to sparse row'
                        }
                ];
 

-- 
To view, visit https://gerrit.wikimedia.org/r/304585
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib243825fe33704a07639b4289d7f4ceff052f7d7
Gerrit-PatchSet: 2
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <esand...@wikimedia.org>
Gerrit-Reviewer: DLynch <dly...@wikimedia.org>
Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to