-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
gapEndIndex = this._findGapEndIndex(gapStartIndex); | ||
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 commentThe 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 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. 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. |
||
continue; | ||
} | ||
|
||
|
@@ -108,8 +112,9 @@ export class TileCoordinator { | |
// gap on the next iteration. | ||
this.columnIndex = gapStartIndex + 1; | ||
|
||
// Continue iterating until we find a gap wide enough for this tile. | ||
} while (gapEndIndex - gapStartIndex < tileCols); | ||
// Continue iterating until we find a gap wide enough for this tile. Since gapEndIndex is | ||
// exclusive, gapEndIndex is 0 means we didn't find a gap and should continue. | ||
} while ((gapEndIndex - gapStartIndex < tileCols) || (gapEndIndex == 0)); | ||
|
||
// If we still didn't manage to find a gap, ensure that the index is | ||
// at least zero so the tile doesn't get pulled out of the grid. | ||
|
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 thecolumnIndex
. 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 thecontinue