-
Notifications
You must be signed in to change notification settings - Fork 6.8k
fix(grid): fix mat-grid-tile position bug 11774 #12980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
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.
Can we have unit tests for this?
@@ -91,6 +91,8 @@ export class TileCoordinator { | |||
// If we've reached the end of the row, go to the next row. | |||
if (this.columnIndex + tileCols > this.tracker.length) { | |||
this._nextRow(); | |||
gapStartIndex = this.tracker.indexOf(0, this.columnIndex); |
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.
I'm not sure whether this makes sense. What it does is that it looks for the value 0
, starting from the columnIndex
. Since the array is filled with zeroes (see https://github.com/angular/material2/pull/12980/files#diff-ddccaadf0ea62282a345db62650d07f7R58), it'll always stop at the next match.
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.
The array is not always filled with 0. In this test case, the row 3 and 4 will only have 0 in the cell 5 and 6. Which is the empty cell in that row.
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.
This line actually isn't going to do anything at all. gapStartIndex
is re-written after the continue
@@ -91,6 +91,8 @@ export class TileCoordinator { | |||
// If we've reached the end of the row, go to the next row. | |||
if (this.columnIndex + tileCols > this.tracker.length) { | |||
this._nextRow(); | |||
gapStartIndex = this.tracker.indexOf(0, this.columnIndex); |
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.
This line actually isn't going to do anything at all. gapStartIndex
is re-written after the continue
@@ -99,6 +101,8 @@ export class TileCoordinator { | |||
// If there are no more empty spaces in this row at all, move on to the next row. | |||
if (gapStartIndex == -1) { | |||
this._nextRow(); | |||
gapStartIndex = this.tracker.indexOf(0, this.columnIndex); | |||
gapEndIndex = this._findGapEndIndex(gapStartIndex); |
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.
I believe this also ins't going to do anything, as these will be rewritten after the continue
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.
once the code hit continue, it will skip the rest in the block and jump to the "while" check, without the new lines, the endIndex will remain as the last row.
b929625
to
2f65ffd
Compare
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.
Added unit testing
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.
LGTM
2f65ffd
to
673ffd1
Compare
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.
handle a single cell at the beginning of a new row correctly.
673ffd1
to
371a373
Compare
371a373
to
e1df8b4
Compare
refresh gapStartIndex and gapEndIndex after move to a new row. Otherwise, they become out of sync and causes wrong calculation.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
refresh gapStartIndex and gapEndIndex after move to a new row. Otherwise, they become out of sync and causes wrong calculation.