Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-28438] Android: TableViewSection header displays the first header text for all other headers

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2021-05-07T18:42:30.000+0000
Affected Version/sRelease 10.0.0
Fix Version/sRelease 10.0.0
ComponentsAndroid
LabelsTableView, android, regression
ReporterLokesh Choudhary
AssigneeGary Mathews
Created2021-05-05T21:49:21.000+0000
Updated2021-05-07T18:42:30.000+0000

Description

Steps to reproduce:

1. Use the below code in your app.js:
var win = Ti.UI.createWindow();

var RED = 'Red',
    GREEN = 'Green',
    PURPLE = 'Purple';

var table = Ti.UI.createTableView({
});

var tableSection1 = createSectionForGroup(RED);
var tableSection2 = createSectionForGroup(GREEN);
var tableSection3 = createSectionForGroup(PURPLE);
var tableSection4 = createSectionForGroup(PURPLE);
var tableSection5 = createSectionForGroup(RED);
var tableSection6 = createSectionForGroup(GREEN);
var tableSection7 = createSectionForGroup(PURPLE);
var tableSection8 = createSectionForGroup(PURPLE);
var tableSection9 = createSectionForGroup(RED);
var tableSection10 = createSectionForGroup(GREEN);
var tableSection11 = createSectionForGroup(PURPLE);
var tableSection12 = createSectionForGroup(PURPLE);

var tableRow = Ti.UI.createTableViewRow({
    title: 'Row'
});

var rows = 7;
var i;
for (i = 0; i <= rows; i++) {
    tableSection1.add(tableRow);
}

for (i = 0; i <= rows; i++) {
    tableSection2.add(tableRow);
}

for (i = 0; i <= rows; i++) {
    tableSection3.add(tableRow);
}

for (i = 0; i <= rows; i++) {
    tableSection4.add(tableRow);
}

for (i = 0; i <= rows; i++) {
    tableSection5.add(tableRow);
}

for (i = 0; i <= rows; i++) {
    tableSection6.add(tableRow);
}

for (i = 0; i <= rows; i++) {
    tableSection7.add(tableRow);
}

for (i = 0; i <= rows; i++) {
    tableSection8.add(tableRow);
}

for (i = 0; i <= rows; i++) {
    tableSection9.add(tableRow);
}

for (i = 0; i <= rows; i++) {
    tableSection10.add(tableRow);
}

for (i = 0; i <= rows; i++) {
    tableSection11.add(tableRow);
}

for (i = 0; i <= rows; i++) {
    tableSection12.add(tableRow);
}

table.setData([tableSection1, tableSection2, tableSection3, tableSection4, tableSection5, tableSection6, tableSection7, tableSection8,
    tableSection9, tableSection10, tableSection11, tableSection12
]);

function createSectionForGroup(group) {
    var headerContainerOpts, headerBottomBorderOpts, headerViewOpts;

    headerViewOpts = {
        color: 'white',
        height: Ti.UI.SIZE,
        font: {
            fontSize: '17sp',
            fontWeight: 'bold'
        },
        left: 11,
        text: group
    };

    if (group === RED) {
        headerContainerOpts = {
            backgroundGradient: {
                endPoint: {
                    x: 0,
                    y: '100%'
                },
                startPoint: {
                    x: 0,
                    y: 0
                },
                type: 'linear',
                colors: ['#C53019', '#B32D14']
            },
            height: 32
        };
    }
    if (group === GREEN) {
        headerContainerOpts = {
            backgroundGradient: {
                endPoint: {
                    x: 0,
                    y: '100%'
                },
                startPoint: {
                    x: 0,
                    y: 0
                },
                type: 'linear',
                colors: ['#2B781E', '#195010']
            },
            height: 32
        };
    }
    if (group === PURPLE) {
        headerContainerOpts = {
            backgroundGradient: {
                endPoint: {
                    x: 0,
                    y: '100%'
                },
                startPoint: {
                    x: 0,
                    y: 0
                },
                type: 'linear',
                colors: ['#873DA6', '#612A7D']
            },
            height: 32
        };
    }

    var container = Ti.UI.createView(headerContainerOpts);
    container.add(Ti.UI.createLabel(headerViewOpts));
    return Ti.UI.createTableViewSection({
        headerView: container,
        title: group
    });
}

win.add(table);
win.open();
2. Build for android device. 3. After the app launches observe the header text.

Actual results:

1. All the following header text's are "Purple".

Expected results:

1. The headers should Red ,Green,Purple, Purple,Red ,Green,Purple, Purple,Red ,Green,Purple, Purple.

Comments

  1. Joshua Quick 2021-05-05

    [~gmathews], the unusual thing in the above code is that same TableViewRow instance is being added multiple times to the TableView under different sections. That's likely the root cause. Probably a cloning issue. I doubt this issue would happen if every section had its own row instances like how it's normally set up.
  2. Gary Mathews 2021-05-06

    master: https://github.com/appcelerator/titanium_mobile/pull/12778
  3. Christopher Williams 2021-05-07

    merged to master and 10_0_X branches

JSON Source