【问题标题】:Label position of an Angular Material nested Stepper gets overwrittenAngular Material 嵌套 Stepper 的标签位置被覆盖
【发布时间】:2021-02-25 14:13:53
【问题描述】:

查看嵌套的 Angular Material Stepper,子步进器 (labelPosition="end") 中的标签位置被父步进器 (@987654323) 中的标签位置覆盖 @),如下例所示:

<mat-horizontal-stepper labelPosition="bottom" linear #stepper>
    <mat-step [stepControl]="firstFormGroup" [editable]="isEditable">
        <ng-template matStepLabel>ParentLabel</ng-template>
        <mat-horizontal-stepper labelPosition="end" linear #stepperChild>
            <mat-step [stepControl]="firstFormGroup" [editable]="isEditable">
                <form [formGroup]="firstFormGroup">
                    <ng-template matStepLabel>ChildLabel</ng-template>
                    <mat-form-field>
                        <mat-label>Name</mat-label>
                        <input matInput
                          formControlName="firstCtrl"
                          placeholder="Last name, First name"
                          required
                        />
                    </mat-form-field>
                </form>
            </mat-step>
        </mat-horizontal-stepper>
    </mat-step>
</mat-horizontal-stepper>

Here's a Stackblitz 展示了这个问题。有没有办法解决这个问题?

【问题讨论】:

    标签: angular angular-material angular-material-stepper


    【解决方案1】:

    如果您稍微研究一下 Angular Material 源代码(当前为 11.2),您可以根据 labelPosition 了解这些类是如何在内部应用的。

    material/stepper/stepper.ts

    '[class.mat-stepper-label-position-end]': 'labelPosition == "end"',
    '[class.mat-stepper-label-position-bottom]': 'labelPosition == "bottom"',
    

    浏览样式表 (material/stepper/stepper.scss),您可以看到 label-position-end 实际上没有应用任何样式。 label-position-bottom 但是有一些样式属性,它们应用于它的所有孩子

    这可能是 Angular Material 本身的一个错误,因为样式的范围不能容纳嵌套的步进器。也可能是嵌套的步进器是无意的。

    angular/components 中打开一个问题以与开发人员联系。或者创建一个 PR。

    【讨论】:

      猜你喜欢
      • 2018-08-08
      • 2019-09-28
      • 2018-05-27
      • 2019-02-15
      • 2020-01-01
      • 2020-06-13
      • 2013-11-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多