Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(abc:st): misalignment when fixed and expand is set #1872

Merged
merged 1 commit into from
Jan 19, 2025
Merged
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
8 changes: 5 additions & 3 deletions packages/abc/st/st-column-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface STColumnSourceProcessOptions {
widthMode: STWidthMode;
resizable?: STResizable;
safeType: STColumnSafeType;
expand: boolean;
}

@Injectable()
Expand Down Expand Up @@ -140,12 +141,13 @@ export class STColumnSource {
}
}

private fixedCoerce(list: _STColumn[]): void {
private fixedCoerce(list: _STColumn[], expand: boolean): void {
const countReduce = (a: number, b: _STColumn): number => a + +b.width!.toString().replace('px', '');
const expandWidth = expand ? 50 : 0;
// left width
list
.filter(w => w.fixed && w.fixed === 'left' && w.width)
.forEach((item, idx) => (item._left = `${list.slice(0, idx).reduce(countReduce, 0)}px`));
.forEach((item, idx) => (item._left = `${list.slice(0, idx).reduce(countReduce, 0) + expandWidth}px`));
// right width
list
.filter(w => w.fixed && w.fixed === 'right' && w.width)
Expand Down Expand Up @@ -536,7 +538,7 @@ export class STColumnSource {
throw new Error(`[st]: just only one column radio`);
}

this.fixedCoerce(columns as _STColumn[]);
this.fixedCoerce(columns as _STColumn[], options.expand);
return {
columns: columns.filter(w => !Array.isArray(w.children) || w.children.length === 0),
...this.genHeaders(copyList)
Expand Down
3 changes: 2 additions & 1 deletion packages/abc/st/st.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
@for (row of _headers; track row) {
<tr>
@if ($first && expand) {
<th nzWidth="50px" [rowSpan]="_headers.length"></th>
<th nzWidth="50px" [rowSpan]="_headers.length" [nzLeft]="row[0].column._left! ? true : false"></th>
}
@for (h of row; track h; let index = $index; let last = $last) {
@let _c = h.column;
Expand Down Expand Up @@ -164,6 +164,7 @@
(nzExpandChange)="_expandChange(i, $event)"
(click)="_stopPropagation($event)"
nzWidth="50px"
[nzLeft]="_columns[0]._left! ? true : false"
></td>
<ng-template #wrapExpandIcon>
<span (click)="_expandChange(i, !i.expand)">
Expand Down
3 changes: 2 additions & 1 deletion packages/abc/st/st.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,8 @@ export class STComponent implements AfterViewInit, OnChanges {
const res = this.columnSource.process(this.columns as _STColumn[], {
widthMode: this.widthMode,
resizable: this._resizable,
safeType: this.cog.safeType as STColumnSafeType
safeType: this.cog.safeType as STColumnSafeType,
expand: this.expand != null
});
this._columns = res.columns;
this._headers = res.headers;
Expand Down
10 changes: 8 additions & 2 deletions packages/abc/st/test/st-column-source.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@ describe('st: column-source', () => {
let rowSrv: STRowSource;
let stWidgetRegistry: STWidgetRegistry;
let page: PageObject;
const options: STColumnSourceProcessOptions = { widthMode, resizable: { disabled: true }, safeType: 'safeHtml' };
const options: STColumnSourceProcessOptions = {
widthMode,
resizable: { disabled: true },
safeType: 'safeHtml',
expand: false
};

function genModule(other: { acl?: boolean; i18n?: boolean; cog?: any }): void {
aclSrv = other.acl ? new ACLService({ merge: (_: any, def: any) => def } as any) : null;
Expand Down Expand Up @@ -228,7 +233,8 @@ describe('st: column-source', () => {
it('should be working when className is object', () => {
const res = srv.process([{ title: '', width: 10, type: 'number', className: { a: true, b: false } }], {
widthMode: { strictBehavior: 'truncate' },
safeType: 'html'
safeType: 'html',
expand: false
}).columns;
const obj = res[0]._className as NgClassInterface;
expect(obj['text-truncate']).toBe(true);
Expand Down
Loading