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(form): fix buttons misalignment in inline layout #1442

Merged
merged 1 commit into from Feb 14, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/form/src/sf-item.component.ts
Expand Up @@ -5,6 +5,7 @@ import {
OnChanges,
OnDestroy,
OnInit,
TemplateRef,
ViewChild,
ViewContainerRef,
ViewEncapsulation
Expand All @@ -23,7 +24,10 @@ let nextUniqueId = 0;
selector: 'sf-item',
exportAs: 'sfItem',
host: { '[class.sf__item]': 'true' },
template: ` <ng-template #target></ng-template> `,
template: `
<ng-template #target></ng-template>
<ng-container *ngTemplateOutlet="footer"></ng-container>
`,
preserveWhitespaces: false,
encapsulation: ViewEncapsulation.None
})
Expand All @@ -33,9 +37,10 @@ export class SFItemComponent implements OnInit, OnChanges, OnDestroy {
widget: Widget<FormProperty, SFUISchemaItem> | null = null;

@Input() formProperty!: FormProperty;
@Input() footer: TemplateRef<void> | null = null;

@ViewChild('target', { read: ViewContainerRef, static: true })
container!: ViewContainerRef;
private container!: ViewContainerRef;

constructor(private widgetFactory: WidgetFactory, private terminator: TerminatorService) {}

Expand Down
6 changes: 4 additions & 2 deletions packages/form/src/sf.component.html
@@ -1,8 +1,7 @@
<ng-template #con>
<ng-content></ng-content>
</ng-template>
<form nz-form [nzLayout]="layout" (submit)="onSubmit($event)" [attr.autocomplete]="autocomplete">
<sf-item *ngIf="rootProperty" [formProperty]="rootProperty"></sf-item>
<ng-template #btnTpl>
<ng-container *ngIf="button !== 'none'; else con">
<nz-form-item
*ngIf="_btn && _btn.render"
Expand Down Expand Up @@ -70,4 +69,7 @@
</div>
</nz-form-item>
</ng-container>
</ng-template>
<form nz-form [nzLayout]="layout" (submit)="onSubmit($event)" [attr.autocomplete]="autocomplete">
<sf-item *ngIf="rootProperty" [formProperty]="rootProperty" [footer]="btnTpl"></sf-item>
</form>
10 changes: 1 addition & 9 deletions packages/form/src/style/index.less
Expand Up @@ -110,15 +110,6 @@
}
}

&__checkbox-list {
display: block;
width: 100%;
@media (min-width: @mobile-min) {
.@{ant-prefix}-col {
margin-top: 8px;
}
}
}
// upload
.@{ant-prefix}-upload-select-picture-card i {
color: #999;
Expand Down Expand Up @@ -184,6 +175,7 @@
}

&-btns {
display: inline-block;
margin-right: 0;
}
}
Expand Down