Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18476] iOS: After a Popover hides, Apps stop getting focus events on Tabs’ windows

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2015-06-10T00:12:09.000+0000
Affected Version/sRelease 3.5.0
Fix Version/sRelease 4.1.0
ComponentsiOS
Labelsios, ipad, popover
ReporterPier Paolo Ramon
AssigneeVishal Duggal
Created2015-01-29T10:52:39.000+0000
Updated2015-06-10T00:12:13.000+0000

Description

When you open a Popover and then hide it you stop getting focus events on the Tabs and on the Tabs’ Windows. You still get focus events on the TabGroup itself. Opening a modal Window and closing it restores the situation to the normal behaviour. With the attached code as app.js follow this steps to better understand the issue. Reproduced is also the modal’s restoring effect.

Steps

Click on the second tab

Click on the "Open popover"

Click on "close" (or click outside the popover)

Click on the first tab

Click on the "Open modal" button

Click on the "close" button

Click on the second tab

Expected result

[ERROR] :  Received focus for TabGroup
[ERROR] :  Received focus for Tab 1
[ERROR] :  Received focus for Window 1
[ERROR] :  Received focus for TabGroup
[ERROR] :  Received focus for Tab 2
[ERROR] :  Received focus for Window 2
[ERROR] :  Received focus for TabGroup
[ERROR] :  Received focus for Tab 1       # THIS LINE IS MISSING
[ERROR] :  Received focus for Window 1    # THIS LINE IS MISSING
[ERROR] :  Received focus for Modal
[ERROR] :  Received focus for Window 1
[ERROR] :  Received focus for Tab 1
[ERROR] :  Received close for Modal
[ERROR] :  Received focus for TabGroup
[ERROR] :  Received focus for Window 2
[ERROR] :  Received focus for Tab 2

Actual result

[ERROR] :  Received focus for TabGroup
[ERROR] :  Received focus for Tab 1
[ERROR] :  Received focus for Window 1
[ERROR] :  Received focus for TabGroup
[ERROR] :  Received focus for Tab 2
[ERROR] :  Received focus for Window 2
[ERROR] :  Received focus for TabGroup
[ERROR] :  Received focus for Modal
[ERROR] :  Received focus for Window 1
[ERROR] :  Received focus for Tab 1
[ERROR] :  Received close for Modal
[ERROR] :  Received focus for TabGroup
[ERROR] :  Received focus for Window 2
[ERROR] :  Received focus for Tab 2

Attached code

var tabGroup = Ti.UI.createTabGroup({ title: 'TabGroup' });

var window1 = Ti.UI.createWindow({ title: 'Window 1' });
var window2 = Ti.UI.createWindow({ title: 'Window 2' });

var tab1 = Ti.UI.createTab({ window: window1, title: 'Tab 1' });
var tab2 = Ti.UI.createTab({ window: window2, title: 'Tab 2' });

tabGroup.addTab(tab1);
tabGroup.addTab(tab2);

// Modals

var modalButton = Ti.UI.createButton({ title: 'Open modal' });

window1.add(modalButton);

modalButton.addEventListener('click', function () {
	var close = Ti.UI.createButton({ title: 'close' });

	var modal = Ti.UI.createWindow({ modal: true, title: 'Modal' });

	modal.add(close);

	modal.addEventListener('focus', onEvent);
	modal.addEventListener('close', onEvent);

	close.addEventListener('click', function () {
		modal.close();
	});

	modal.open();
});

// Popover

var popoverButton = Ti.UI.createButton({ title: 'Open popover' });

window2.add(popoverButton);

popoverButton.addEventListener('click', function () {
	var close = Ti.UI.createButton({ title: 'close' });

	var content = Ti.UI.createView({ title: 'Popover Content View' });

	content.backgroundColor = 'white';
	content.width = 200;
	content.height = 200;
	content.add(close);

	var popover = Ti.UI.iPad.createPopover({ contentView: content });

	close.addEventListener('click', function () {
		popover.hide();
	});

	popover.show({ view: popoverButton });
});

// Listeners

[ tabGroup, window1, window2, tab1, tab2 ].forEach(function (view) {
	view.addEventListener('focus', onEvent);
});

function onEvent(event) {
	Ti.API.error("Received " + event.type + " for " + event.source.title);
}

// Open the tab group

tabGroup.open();

Comments

  1. Banzai Mobile 2015-03-03

    This bug effectively prevents use of popovers in our apps. We had to remove popovers completely to update to 3.5.0 I vote for high priority on this.
  2. Vishal Duggal 2015-04-16

    Pull pending master - https://github.com/appcelerator/titanium_mobile/pull/6786
  3. Vishal Duggal 2015-04-22

    As a workaround, you can set the contentView property of the popover to be a Ti.UI.Window proxy. Then you will have consistent behavior on both iOS7 and iOS 8.
  4. Lokesh Choudhary 2015-06-05

    Verified the fix. We now get focus events on tabs & windows after a popover hides. Closing. Environment: Appc Studio : 4.1.0.201505071004 Ti SDK : 4.1.0.v20150604094312 CLI : 4.0.2-rc2 Alloy : 1.6.0 MAC Yosemite : 10.10.3 Appc npm : 4.0.0 Appc CLI : 4.0.1 Node: v0.10.37 IOS Simulator: Ipad Air IOS 8.3

JSON Source