make undefined okay for span options
This commit is contained in:
@@ -47,7 +47,7 @@ export class UmbBlockGridAreaConfigEntryContext
|
||||
}
|
||||
public getRelevantColumnSpanOptions() {
|
||||
const layoutColumns = this.#entriesContext?.getLayoutColumns();
|
||||
if (!layoutColumns) return [this.getColumnSpan() ?? 1]; // Just some fallback option, for this case, not sure if the case is even relevant. [NL]
|
||||
if (!layoutColumns) return;
|
||||
// Makes an array based of the given length, with number entries starting from 1. ex.: length 4 => [1, 2, 3, 4]
|
||||
return Array.from({ length: layoutColumns }, (_, i) => i + 1);
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ export interface UmbBlockGridScalableContext extends UmbControllerHost {
|
||||
getColumnSpan: () => number | undefined;
|
||||
getRowSpan: () => number | undefined;
|
||||
getMinMaxRowSpan: () => [number, number];
|
||||
getRelevantColumnSpanOptions: () => Array<number>;
|
||||
getRelevantColumnSpanOptions: () => Array<number> | undefined;
|
||||
}
|
||||
|
||||
// This might be more generic than Block Grid, but this is where it belongs currently:
|
||||
@@ -190,12 +190,11 @@ export class UmbBlockGridScaleManager extends UmbBaseController {
|
||||
|
||||
let newColumnSpan = Math.max(blockEndCol - blockStartCol, 1);
|
||||
|
||||
const spanOptions = this._host.getRelevantColumnSpanOptions();
|
||||
if (!spanOptions) return;
|
||||
|
||||
// Find nearest allowed Column:
|
||||
const bestColumnSpanOption = closestColumnSpanOption(
|
||||
newColumnSpan,
|
||||
this._host.getRelevantColumnSpanOptions(),
|
||||
layoutColumns - blockStartCol,
|
||||
);
|
||||
const bestColumnSpanOption = closestColumnSpanOption(newColumnSpan, spanOptions, layoutColumns - blockStartCol);
|
||||
newColumnSpan = bestColumnSpanOption ?? layoutColumns;
|
||||
|
||||
const [rowMinSpan, rowMaxSpan] = this._host.getMinMaxRowSpan();
|
||||
|
||||
Reference in New Issue
Block a user