Skip to content

Commit 8def429

Browse files
committed
fix(abc:st): misalignment when fixed and expand is set
- close ng-alain/ng-alain#2534
1 parent 983cedb commit 8def429

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

packages/abc/st/st-column-source.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface STColumnSourceProcessOptions {
2727
widthMode: STWidthMode;
2828
resizable?: STResizable;
2929
safeType: STColumnSafeType;
30+
expand: boolean;
3031
}
3132

3233
@Injectable()
@@ -140,12 +141,13 @@ export class STColumnSource {
140141
}
141142
}
142143

143-
private fixedCoerce(list: _STColumn[]): void {
144+
private fixedCoerce(list: _STColumn[], expand: boolean): void {
144145
const countReduce = (a: number, b: _STColumn): number => a + +b.width!.toString().replace('px', '');
146+
const expandWidth = expand ? 50 : 0;
145147
// left width
146148
list
147149
.filter(w => w.fixed && w.fixed === 'left' && w.width)
148-
.forEach((item, idx) => (item._left = `${list.slice(0, idx).reduce(countReduce, 0)}px`));
150+
.forEach((item, idx) => (item._left = `${list.slice(0, idx).reduce(countReduce, 0) + expandWidth}px`));
149151
// right width
150152
list
151153
.filter(w => w.fixed && w.fixed === 'right' && w.width)
@@ -536,7 +538,7 @@ export class STColumnSource {
536538
throw new Error(`[st]: just only one column radio`);
537539
}
538540

539-
this.fixedCoerce(columns as _STColumn[]);
541+
this.fixedCoerce(columns as _STColumn[], options.expand);
540542
return {
541543
columns: columns.filter(w => !Array.isArray(w.children) || w.children.length === 0),
542544
...this.genHeaders(copyList)

packages/abc/st/st.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
@for (row of _headers; track row) {
5959
<tr>
6060
@if ($first && expand) {
61-
<th nzWidth="50px" [rowSpan]="_headers.length"></th>
61+
<th nzWidth="50px" [rowSpan]="_headers.length" [nzLeft]="row[0].column._left! ? true : false"></th>
6262
}
6363
@for (h of row; track h; let index = $index; let last = $last) {
6464
@let _c = h.column;
@@ -164,6 +164,7 @@
164164
(nzExpandChange)="_expandChange(i, $event)"
165165
(click)="_stopPropagation($event)"
166166
nzWidth="50px"
167+
[nzLeft]="_columns[0]._left! ? true : false"
167168
></td>
168169
<ng-template #wrapExpandIcon>
169170
<span (click)="_expandChange(i, !i.expand)">

packages/abc/st/st.component.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,8 @@ export class STComponent implements AfterViewInit, OnChanges {
10141014
const res = this.columnSource.process(this.columns as _STColumn[], {
10151015
widthMode: this.widthMode,
10161016
resizable: this._resizable,
1017-
safeType: this.cog.safeType as STColumnSafeType
1017+
safeType: this.cog.safeType as STColumnSafeType,
1018+
expand: this.expand != null
10181019
});
10191020
this._columns = res.columns;
10201021
this._headers = res.headers;

packages/abc/st/test/st-column-source.spec.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ describe('st: column-source', () => {
3737
let rowSrv: STRowSource;
3838
let stWidgetRegistry: STWidgetRegistry;
3939
let page: PageObject;
40-
const options: STColumnSourceProcessOptions = { widthMode, resizable: { disabled: true }, safeType: 'safeHtml' };
40+
const options: STColumnSourceProcessOptions = {
41+
widthMode,
42+
resizable: { disabled: true },
43+
safeType: 'safeHtml',
44+
expand: false
45+
};
4146

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

0 commit comments

Comments
 (0)