@@ -194,6 +194,7 @@ function makeComputeWidths(colSpan, desiredWidth, x, forcedMin) {
194
194
return function ( vals , table ) {
195
195
let result = [ ] ;
196
196
let spanners = [ ] ;
197
+ let auto = { } ;
197
198
table . forEach ( function ( row ) {
198
199
row . forEach ( function ( cell ) {
199
200
if ( ( cell [ colSpan ] || 1 ) > 1 ) {
@@ -217,12 +218,20 @@ function makeComputeWidths(colSpan, desiredWidth, x, forcedMin) {
217
218
let col = cell [ x ] ;
218
219
let existingWidth = result [ col ] ;
219
220
let editableCols = typeof vals [ col ] === 'number' ? 0 : 1 ;
220
- for ( let i = 1 ; i < span ; i ++ ) {
221
- existingWidth += 1 + result [ col + i ] ;
222
- if ( typeof vals [ col + i ] !== 'number' ) {
223
- editableCols ++ ;
221
+ if ( typeof existingWidth === 'number' ) {
222
+ for ( let i = 1 ; i < span ; i ++ ) {
223
+ existingWidth += 1 + result [ col + i ] ;
224
+ if ( typeof vals [ col + i ] !== 'number' ) {
225
+ editableCols ++ ;
226
+ }
227
+ }
228
+ } else {
229
+ existingWidth = desiredWidth === 'desiredWidth' ? cell . desiredWidth - 1 : 1 ;
230
+ if ( ! auto [ col ] || auto [ col ] < existingWidth ) {
231
+ auto [ col ] = existingWidth ;
224
232
}
225
233
}
234
+
226
235
if ( cell [ desiredWidth ] > existingWidth ) {
227
236
let i = 0 ;
228
237
while ( editableCols > 0 && cell [ desiredWidth ] > existingWidth ) {
@@ -237,7 +246,7 @@ function makeComputeWidths(colSpan, desiredWidth, x, forcedMin) {
237
246
}
238
247
}
239
248
240
- Object . assign ( vals , result ) ;
249
+ Object . assign ( vals , result , auto ) ;
241
250
for ( let j = 0 ; j < vals . length ; j ++ ) {
242
251
vals [ j ] = Math . max ( forcedMin , vals [ j ] || 0 ) ;
243
252
}
0 commit comments