Ng-zorro-antd: <nz-form-control> in <nz-form-item nzGutter> should generated correct padding

Created on 19 Nov 2018  ·  8Comments  ·  Source: NG-ZORRO/ng-zorro-antd

Version

1.8.0

Environment

Windows 10
Chrome 70.0.3538.102(正式版本) (64 位)
[email protected]

Reproduction link

https://stackblitz.com/edit/ng-zorro-antd-start-z14eiy?file=src%2Fapp%2Fapp.component.html

Steps to reproduce

<nz-form-item nzGutter="8">
  <nz-form-control nzSpan="10">
    <nz-form-text>Col 10 In Form</nz-form-text>
  </nz-form-control>
</nz-form-item>

What is expected?

<nz-form-control> get correct style padding-left: 4px; padding-right: 4px, like [nz-col] in [nz-row].

What is actually happening?

<nz-form-control> has no style, but <nz-form-item> generated margin style.

Other?

Bug Good First Issue

Most helpful comment

Hi, so I have taken a look at it, I discovered that the nz-form-control selector has no padding added, so I have added that, but then once nzSpan directive is added, the padding rule gets overwritten and then set to 0 which are the rules for nzSpan directive. So I added an extra rule to override it

 .@{form-prefix-cls}-item-control-wrapper {
    display: block;
    width: 100%;
    padding-right: 4px; 
    padding-left: 4px;
    &[class^="@{ant-prefix}-col-"] { // adds the padding rules to overwrite the nzSpan directive rules
      padding-right: 4px;
      padding-left: 4px;
    }

is repeating the rules optimal or is there a better way I can do it?

All 8 comments

Hi, I would like to look into this bug if that's okay, please?

@asincole 👏 Sure! Welcome to contribute. Feel free to open a pr.

Alright, great. I have forked already and will start working on it tonight. This is my first Contribution to an OSS, any tips or hints outside the ones in the CONTRIBUTING.md or general tips? @wendzhue

Hi, so I have taken a look at it, I discovered that the nz-form-control selector has no padding added, so I have added that, but then once nzSpan directive is added, the padding rule gets overwritten and then set to 0 which are the rules for nzSpan directive. So I added an extra rule to override it

 .@{form-prefix-cls}-item-control-wrapper {
    display: block;
    width: 100%;
    padding-right: 4px; 
    padding-left: 4px;
    &[class^="@{ant-prefix}-col-"] { // adds the padding rules to overwrite the nzSpan directive rules
      padding-right: 4px;
      padding-left: 4px;
    }

is repeating the rules optimal or is there a better way I can do it?

@asincole You can just create a pr and we would review your code there.

@wendzhue alright. I'll do it in a bit.. sorry about the delay. Thanks.

@issuehuntfest has funded $20.00 to this issue. See it on IssueHunt

fixed in https://github.com/NG-ZORRO/ng-zorro-antd/pull/2493/files#diff-611562526e66dba4ffd92fb8fa6cdd54R126

Was this page helpful?
0 / 5 - 0 ratings