diff --git a/packages/grid/src/index.ts b/packages/grid/src/index.ts index 7a0193a6677..580b56c4d86 100644 --- a/packages/grid/src/index.ts +++ b/packages/grid/src/index.ts @@ -311,24 +311,42 @@ export class Grid { const baseColumns = this.childSize - const maxWidthColumns = Math.min( + const strictMaxWidthColumns = Math.round( + this.width / (this.maxWidth + this.columnGap) + ) + + const looseMaxWidthColumns = Math.min( originTotalColumns, - Math.round(this.width / (this.maxWidth + this.columnGap)) + strictMaxWidthColumns + ) + + const maxWidthColumns = this.options.strictAutoFit + ? strictMaxWidthColumns + : looseMaxWidthColumns + + const strictMinWidthColumns = Math.round( + this.width / (this.minWidth + this.columnGap) ) - const minWidthColumns = Math.min( + const looseMinWidthColumns = Math.min( originTotalColumns, - Math.round(this.width / (this.minWidth + this.columnGap)) + strictMinWidthColumns ) + const minWidthColumns = this.options.strictAutoFit + ? strictMinWidthColumns + : looseMinWidthColumns + const minCalculatedColumns = Math.min( baseColumns, + originTotalColumns, maxWidthColumns, minWidthColumns ) const maxCalculatedColumns = Math.max( baseColumns, + originTotalColumns, maxWidthColumns, minWidthColumns )