Skip to content

Commit

Permalink
bugfix: allow zero for fillColumnIndex
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Bryxí committed Sep 13, 2019
1 parent 3aa2645 commit 619302c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion addon/-private/column-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { scheduler, Token } from 'ember-raf-scheduler';
import { getOrCreate } from './meta-cache';
import { objectAt, move, splice } from './utils/array';
import { mergeSort } from './utils/sort';
import { isEmpty } from '@ember/utils';
import { getScale, getOuterClientRect, getInnerClientRect } from './utils/element';
import { MainIndicator, DropIndicator } from './utils/reorder-indicators';
import { notifyPropertyChange } from './utils/ember';
Expand Down Expand Up @@ -653,7 +654,7 @@ export default EmberObject.extend({
} else if (fillMode === FILL_MODE.LAST_COLUMN) {
this.resizeColumn(columns.length - 1, delta);
} else if (fillMode === FILL_MODE.NTH_COLUMN) {
assert("fillMode 'nth-column' must have a fillColumnIndex defined", fillColumnIndex);
assert("fillMode 'nth-column' must have a fillColumnIndex defined", !isEmpty(fillColumnIndex));
this.resizeColumn(fillColumnIndex, delta);
}
}
Expand Down
24 changes: 23 additions & 1 deletion tests/integration/components/headers/main-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,34 @@ module('Integration | header | main', function() {
);
});

test('nth column mode for first column', async function(assert) {
let columnWidth = 30;

await generateTable(this, {
fillMode: 'nth-column',
fillColumnIndex: 0,
widthConstraint: 'eq-container',
columnCount: 3,
columnOptions: {
width: columnWidth,
},
});

let tableWidth = table.width;
let middleColumnWidth = table.headers.objectAt(0).width;

assert.ok(
Math.abs(tableWidth - middleColumnWidth - 2 * columnWidth) <= 1,
'nth column takes extra space in nth column resize mode.'
);
});

test('nth column mode', async function(assert) {
let columnWidth = 30;

await generateTable(this, {
fillMode: 'nth-column',
fillColumnIndex: '1',
fillColumnIndex: 1,
widthConstraint: 'eq-container',
columnCount: 3,
columnOptions: {
Expand Down

0 comments on commit 619302c

Please sign in to comment.