Nativescript-angular: Span renders line break as zero

Created on 22 May 2017  路  3Comments  路  Source: NativeScript/nativescript-angular

_From @triniwiz on May 22, 2017 11:26_

In 2.5.x i used the following to get a simple icon above some text design

<Button [nsRouterLinkActiveOptions]="{exact:true }" [nsRouterLinkActive]="['active']" [nsRouterLink]="item.menuLink" textWrap="true">
        <FormattedString>
            <Span [icon]="item.icon" [fontSize]="item.size ? item.size : '14'" fontFamily="icons"></Span>
            <Span [text]="item.label ? '\n\n' : ''"></Span>
            <Span class="menu-text" [text]="item.label"></Span>
        </FormattedString>
    </Button>

result

screen shot 2017-05-01 at 11 41 03 am

In 3.0.x it results in the following

screen shot 2017-05-19 at 10 16 49 pm

tns 3.0.1
tns-ios 3.0.0
core-modules: 3.0.0 and next

_Copied from original issue: NativeScript/NativeScript#4251_

backlog bug ios low

Most helpful comment

Hi @triniwiz,
Thank you for reporting this issue,
I tested this case on my side and indeed this is a real issue in NativeScirpt Angular 2 application. This problem is not reproducible in while using a pure NativeScirpt app.
As a workaround, you could use the below-attached code, where the check, if there is text available, is made on the second span.
Example:

<StackLayout class="page">
    <GridLayout rows="" columns="">
        <Button  textWrap="true">
            <FormattedString>
                <Span fontFamily="FontAwesome" [text]="title" fontSize="14" ></Span>
                <Span class="menu-text" [text]="label ? '\n\n'+label : ''"></Span>
            </FormattedString>
        </Button>
    </GridLayout>
</StackLayout>

All 3 comments

Hi @triniwiz,
Thank you for reporting this issue,
I tested this case on my side and indeed this is a real issue in NativeScirpt Angular 2 application. This problem is not reproducible in while using a pure NativeScirpt app.
As a workaround, you could use the below-attached code, where the check, if there is text available, is made on the second span.
Example:

<StackLayout class="page">
    <GridLayout rows="" columns="">
        <Button  textWrap="true">
            <FormattedString>
                <Span fontFamily="FontAwesome" [text]="title" fontSize="14" ></Span>
                <Span class="menu-text" [text]="label ? '\n\n'+label : ''"></Span>
            </FormattedString>
        </Button>
    </GridLayout>
</StackLayout>

@tsonevn Hi . I didn't want to open a new bug but it also happen in other variation with android.

Let's draw :

444
123

Code :

image

Result ( OK) :

image

Now let's add :

image

Problem :

image

It should be opened as it doesn't respect ngIf.

Update :

seems that putting two ngIf does solve it :

image

REsult :
image

Additional Info

image

@tsonevn Hi . I didn't want to open a new bug but it also happen in other variation with android.

Let's draw :

444
123

Code :

image

Result ( OK) :

image

Now let's add :

image

Problem :

image

It should be opened as it doesn't respect ngIf.

Update :

seems that putting two ngIf does solve it :

image

REsult :
image

Additional Info

image

That *ngIf problem was exactly what I was facing. Your solution resolved it for me! Thanks!

Was this page helpful?
0 / 5 - 0 ratings