Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2682,7 +2682,7 @@ export class IgxColumnComponent implements AfterContentInit, OnDestroy, ColumnTy
} else if (this.minWidth && newSize <= this.userSetMinWidthPx) {
this.widthConstrained = true;
return this.userSetMinWidthPx;
} else if (!this.minWidth && (!this.widthSetByUser || this.width === 'fit-content') && !this.grid.columnWidthSetByUser && (!newSize || newSize <= this.grid.minColumnWidth)) {
} else if ((this.columnLayout || !this.columnGroup) && !this.minWidth && (!this.widthSetByUser || this.width === 'fit-content') && !this.grid.columnWidthSetByUser && (!newSize || newSize <= this.grid.minColumnWidth)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why the AI agent decided that the MRL (column layout) scenario should be included here as the same issue where the widths don't match happens with a igx-column-layout, where the sum of the child column widths is less than the minColumnWidth.

Constraint should be skipped for both IMO as their width is the sum of the child columns, where the children themselves already apply the constraint.

Suggested change
} else if ((this.columnLayout || !this.columnGroup) && !this.minWidth && (!this.widthSetByUser || this.width === 'fit-content') && !this.grid.columnWidthSetByUser && (!newSize || newSize <= this.grid.minColumnWidth)) {
} else if (!this.columnGroup && !this.minWidth && (!this.widthSetByUser || this.width === 'fit-content') && !this.grid.columnWidthSetByUser && (!newSize || newSize <= this.grid.minColumnWidth)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, Maya, for actually reviewing this. My intention is not fixing the bug, but testing how a new custom bug-fixing-agent undertakes the whole process of fixing a bug.
On your point, I've ran this agent a dozen times now, with different models and tweaks and some times it adds
&& (this.columnLayout || !this.columnGroup)
sometimes just
&& !this.columnGroup
I still don't see a pattern when it's pivoting to one or the other, but you're feedback is useful.
Don't bother of further reviewing or merging copilot's PRs on this issue. I'm also testing how he assembles PR's so you'll se more of them.

return this.grid.minColumnWidth;
Comment on lines 2684 to 2686
} else {
this.widthConstrained = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,55 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import {
CollapsibleColumnGroupTestComponent,
CollapsibleGroupsTemplatesTestComponent,
CollapsibleGroupsDynamicColComponent
CollapsibleGroupsDynamicColComponent,
CollapsibleColumnGroupWithExplicitWidthsComponent
} from '../../../test-utils/grid-samples.spec';
import { GridFunctions } from '../../../test-utils/grid-functions.spec';
import { UIInteractions, wait } from '../../../test-utils/ui-interactions.spec';
import { DropPosition } from 'igniteui-angular/grids/core';
import { IgxColumnGroupComponent } from 'igniteui-angular/grids/core';
import { SortingDirection } from 'igniteui-angular/core';

describe('IgxGrid - collapsible column group with explicit widths regression #17042 #grid', () => {
let fixture;
let grid: IgxGridComponent;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [
NoopAnimationsModule,
CollapsibleColumnGroupWithExplicitWidthsComponent
]
}).compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(CollapsibleColumnGroupWithExplicitWidthsComponent);
fixture.detectChanges();
grid = fixture.componentInstance.grid;
});

it('collapsed column group calcPixelWidth should equal the sum of visible children calcPixelWidth when columns have explicit widths smaller than minColumnWidth', () => {
const colGroup = grid.getColumnByName('ID').parent as IgxColumnGroupComponent;
const visibleChild = grid.getColumnByName('ID');

// Group is collapsed by default (expanded=false in the template)
expect(colGroup.collapsible).toBeTrue();
expect(colGroup.expanded).toBeFalse();

// The visible child has explicit width 100px, which is less than the grid's MINIMUM_COLUMN_WIDTH (136px).
// The column group's calcPixelWidth should equal its visible child's calcPixelWidth,
// NOT be inflated to the grid's minimum column width.
const visibleChildWidth = visibleChild.calcPixelWidth;
const groupWidth = colGroup.calcPixelWidth;

expect(visibleChildWidth).toBe(100);
expect(groupWidth).toBe(visibleChildWidth,
`Column group calcPixelWidth (${groupWidth}) should equal the visible child calcPixelWidth (${visibleChildWidth}). ` +
`The group header must not be inflated by minColumnWidth because that causes header/cell misalignment.`);
});
});

describe('IgxGrid - multi-column headers #grid', () => {
let contactInf;
let countryInf;
Expand Down
28 changes: 28 additions & 0 deletions projects/igniteui-angular/test-utils/grid-samples.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2009,6 +2009,34 @@ export class CollapsibleGroupsDynamicColComponent {
}
}

/**
* Test component for verifying that a collapsed collapsible column group with explicit column widths
* smaller than the grid's MINIMUM_COLUMN_WIDTH does not cause header/cell misalignment.
* Regression test for: https://github.com/IgniteUI/igniteui-angular/issues/17042
*/
@Component({
template: `
<igx-grid #grid [data]="data" height="500px" width="900px">
<igx-column-group header="Customer Information" [collapsible]="true" [expanded]="false">
<igx-column field="ID" width="100px" [visibleWhenCollapsed]="true"></igx-column>
<igx-column field="CompanyName" width="100px" [visibleWhenCollapsed]="false"></igx-column>
<igx-column field="ContactName" width="100px" [visibleWhenCollapsed]="false"></igx-column>
</igx-column-group>
<igx-column field="ContactTitle"></igx-column>
<igx-column field="Address"></igx-column>
<igx-column field="City"></igx-column>
<igx-column field="Country"></igx-column>
<igx-column field="Phone"></igx-column>
</igx-grid>
`,
imports: [IgxGridComponent, IgxColumnComponent, IgxColumnGroupComponent]
})
export class CollapsibleColumnGroupWithExplicitWidthsComponent {
@ViewChild(IgxGridComponent, { read: IgxGridComponent, static: true })
public grid: IgxGridComponent;
public data = SampleTestData.contactInfoDataFull();
}

@Component({
template: `
<igx-grid #grid [data]="data" height="500px" width="1300px" columnWidth="100px">
Expand Down
Loading