Skip to content

text decoration on Label is lost after rendering a label using HTMLLabel #25

@fpaaske

Description

@fpaaske

How to reproduce:

Create a new project: ns create ui-label-test --ng
cd ui-label-test
Update items.component.html to include textDecoration="underline"

<ActionBar title="My App"> </ActionBar>

<GridLayout>
  <ListView [items]="itemService.items()">
    <ng-template let-item="item">
      <StackLayout [nsRouterLink]="['/item', item.id]">
        <Label [text]="item.name" class="text-lg text-gray-500 p-4"
          textDecoration="underline"
        ></Label>
      </StackLayout>
    </ng-template>
  </ListView>
</GridLayout>

Run the app: ns run ios --emulator

Observe the text decoration working fine.

Add the plugin: npm i @nativescript-community/ui-label
Register the HTMLLabel in app.component.ts: registerElement('HTMLLabel', () => require('@nativescript-community/ui-label').Label);
Add an HTMLLabel in the template:

<ActionBar title="My App"> </ActionBar>

<GridLayout>
  <ListView [items]="itemService.items()">
    <ng-template let-item="item">
      <StackLayout [nsRouterLink]="['/item', item.id]">
        <Label [text]="item.name" class="text-lg text-gray-500 p-4"
          textDecoration="underline"
        ></Label>
        <HTMLLabel>This is an HTMLLabel</HTMLLabel>
      </StackLayout>
    </ng-template>
  </ListView>
</GridLayout>

Run the app: ns run ios --emulator

Observe that the text decoration is now gone.


You can also move the HTMLLabel to the item-detail.component.html. Then text decoration works fine until you navigate to the details, and back. When scrolling the list now, the underline disappears on the re-rendered list entries.

package.json

{
  "name": "ns-ng-ui-label-test",
  "main": "./src/main.ts",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "@angular/animations": "~19.0.0",
    "@angular/common": "~19.0.0",
    "@angular/compiler": "~19.0.0",
    "@angular/core": "~19.0.0",
    "@angular/forms": "~19.0.0",
    "@angular/platform-browser": "~19.0.0",
    "@angular/platform-browser-dynamic": "~19.0.0",
    "@angular/router": "~19.0.0",
    "@nativescript-community/ui-label": "^1.3.33",
    "@nativescript/angular": "^19.0.0",
    "@nativescript/core": "~8.8.0",
    "rxjs": "~7.8.0",
    "zone.js": "~0.15.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~19.0.0",
    "@angular/compiler-cli": "~19.0.0",
    "@nativescript/ios": "8.7.2",
    "@nativescript/tailwind": "^2.1.0",
    "@nativescript/types": "~8.8.0",
    "@nativescript/webpack": "~5.0.0",
    "@ngtools/webpack": "~19.0.0",
    "tailwindcss": "~3.4.0",
    "typescript": "~5.6.0"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions