Skip to content

Background color is lost depending of HtmlView text length #1046

Open
@tsonevn

Description

@tsonevn

From @public-virtualys on October 18, 2017 9:10

Which platform(s) does your issue occur on?

Android

Please provide the following version numbers that your issue occurs with:

  • CLI: 3.2.1
  • Cross-platform modules: 3.2.0
  • Runtime(s): 3.2.0 both
  • Plugin(s): none

Please tell us how to recreate the issue in as much detail as possible.

Get a very basic reusable component, that displays a header and a body with enabled scrolling :

import { Component } from '@angular/core';
@Component({
    selector: 'test-bug-view',
    template: `
            <ScrollView>
                <StackLayout>
                    <StackLayout>
                        <ng-content select="[head]"></ng-content>
                    </StackLayout>
                    <StackLayout>
                        <ng-content select="[body]"></ng-content>
                    </StackLayout>
                </StackLayout>
            </ScrollView>`
})
export class TestBugComponent
{
}

Then use it in a page, displaying some html paragraphs :

import { Component, OnInit } from "@angular/core";

@Component({
    moduleId: module.id,
    selector: "my-component",
    template: 
        `<test-bug-view>
            <StackLayout head backgroundColor="red">
                <Label class="h2" text="Header" horizontalAlignement="center" verticalAlignement="center"></Label>
            </StackLayout>
            <StackLayout body backgroundColor="yellow">
                <HtmlView class="body" [html]="text" backgroundColor="green"></HtmlView>
            </StackLayout>
        </test-bug-view>`
})
export class SettingsComponent implements OnInit
{
    private _text: string;

    public get text(): string {
        return this._text;
    }

    public ngOnInit(): void {
        const line: string = `<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis non pretium erat. Sed efficitur ultricies ultrices. Vestibulum euismod et orci sed elementum. Mauris lorem nisi, viverra eu enim ac, porta interdum neque. Maecenas porta purus quis lectus porta vestibulum. Sed et ipsum metus. Cras ex ex, aliquet ut felis quis, commodo rutrum erat. Maecenas luctus nibh sit amet sem maximus aliquam. Curabitur a lacinia libero. Aliquam euismod nec nulla quis volutpat. In vel ultrices orci, eget imperdiet enim. In egestas vehicula tincidunt. Vestibulum et magna semper, dapibus magna non, sagittis elit. Etiam dictum, magna in rutrum tristique, ante elit porttitor massa, vel iaculis erat magna sit amet leo. Phasellus neque lorem, bibendum quis eleifend vel, posuere ut enim.</p>`;
        let text: string = "";
        for (let i = 0; i < 8; ++i) {
            text += line;
        }
        this._text = text;
    }
}

It works as expected, with header having a red background color, and HTML text a green one.

Now, increase HtmlView bounds in adding some extra paragraphs : change the for loop bound to 30 instead of 8. Then the problem occurs : the HtmlView successfully displays all the 30 paragraphs of text, but there is no more background color under it - neither green nor even yellow.

Simulated on an emulated device using AVD, and reproduced on an Sony Xperia Z3 Tablet Compact / Android 6.0.1.

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

Given on the previous paragraph.

Copied from original issue: NativeScript/NativeScript#4961

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions