Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): amend ListView behaviour when search view is defined #12678

Merged
merged 7 commits into from Apr 8, 2021

Conversation

garymathews
Copy link
Contributor

@garymathews garymathews commented Mar 30, 2021

  • Amend how ListView and TableView are constructed when a searchView is added
    • Prevent rendering issues when a borderRadius is applied
  • Fix TableView row index when a search query is applied
TEST CASE 1
const win = Ti.UI.createWindow({
    backgroundColor: 'white'
});
const search = Ti.UI.createSearchBar({
    //borderWidth: 5, // QE: Validate borders are visible.
    //borderColor: 'orange'
});
const sections = [];
for (let i = 0; i < 3; i++) {
    const items = [];
    for (let x = 0; x < 5; x++) {
        const text = `Item #${x}`;
        items.push({
            properties: {
                searchableText: text
            },
            label: {
                text
            }
        });
    }
    sections.push(Ti.UI.createListSection({
        headerTitle: `Section #${i}`,
        items
    }));
}
const listView = Ti.UI.createListView({
    templates: {
        template: {
            properties: {
                backgroundColor: 'transparent'
            },
            childTemplates: [{
                type: 'Ti.UI.Label',
                bindId: 'label',
                properties: {
                    left: 10,
                    color: 'black'
                }
            }]
        }
    },
    backgroundColor: 'blue',
    defaultItemTemplate: 'template',
    borderRadius: 8,
    searchView: search,
    sections
});
const btn = Ti.UI.createButton({
    bottom: 10,
    title: 'Toggle Search'
});
btn.addEventListener('click', e => {
    listView.searchView = listView.searchView ? null : search;
});
win.add([listView, btn]);
win.open();
TEST CASE 2
const win = Titanium.UI.createWindow({
	backgroundColor: 'gray'
});
const search = Ti.UI.createSearchBar({
	hintText: 'Search...',
	showCancel: false
});
const btn = Ti.UI.createButton({ bottom: 10, title: 'Toggle Search' });

btn.addEventListener('click', e => {
	tableView.search = tableView.search ? null : search;
});

function createSection(rows, suffix) {
	const section = Ti.UI.createTableViewSection({
		headerTitle: `Section ${suffix}`
	});

	for (let i = 1; i <= rows; i++) {
		section.add(Ti.UI.createTableViewRow({
			title: `Row #${i}`
		}));
	}

	return section;
}

const tableView = Ti.UI.createTableView({
	data: [
		createSection(10, 'A'),
		createSection(10, 'B'),
		createSection(10, 'C')
	],
	search
});

tableView.addEventListener('noresults', e => {
	alert('NO RESULTS!');
});

win.add([ tableView, btn ]);
win.open();

JIRA Ticket

@garymathews garymathews added android bug no tests backport 10_2_X when applied, PRs with this label will get an auto-generated backport to 10_2_X branch on merge labels Mar 30, 2021
@garymathews garymathews added this to the 10.1.0 milestone Mar 30, 2021
@build build requested a review from a team March 30, 2021 22:32
@build
Copy link
Contributor

build commented Mar 30, 2021

Fails
🚫 Tests have failed, see below for more information.
Messages
📖 ✊ The commits in this PR match our conventions! Feel free to Rebase and Merge this PR when ready.
📖 ❌ 2 tests have failed There are 2 tests failing and 961 skipped out of 15275 total tests.
📖

💾 Here's the generated SDK zipfile.

Tests:

ClassnameNameTimeError
ios.iphone.Titanium.Geolocation.methods#reverseGeocoder() works via function callback (14.4.0)0.062
Error: expected false to be true
value@file:///node_modules/should/cjs/should.js:356:23
file:///ti.geolocation.test.js:645:44
ios.macos.Titanium.Blobimage dimensions should be reported in pixels (10.15.5)0.048
Error: expected 6 to be 11
value@file:///node_modules/should/cjs/should.js:356:23
postlayout@file:///ti.blob.test.js:488:33

Generated by 🚫 dangerJS against 15907ac

Copy link
Contributor

@jquick-axway jquick-axway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CR: Pass

@lokeshchdhry
Copy link
Contributor

@garymathews , I am not able to search in TestCase 1 for Listview.

@garymathews
Copy link
Contributor Author

@lokeshchdhry The test case didn't set the searchableText property on the ListItems. I've updated the test case so it's searchable.

@lokeshchdhry
Copy link
Contributor

FR Passed.

@sgtcoolguy sgtcoolguy merged commit 9b27f4b into tidev:master Apr 8, 2021
@build build removed the backport 10_2_X when applied, PRs with this label will get an auto-generated backport to 10_2_X branch on merge label Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants