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(ios): fire blur event when TabGroup focus is removed #12207

Merged
merged 2 commits into from
Nov 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions iphone/Classes/TiUITabGroupProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ - (void)gainFocus

- (void)resignFocus
{
if ([self _hasListeners:@"blur"]) {
// focus event and blur event has same parameters
NSDictionary *event = [((TiUITabGroup *)self.view) focusEvent];
[self fireEvent:@"blur" withObject:event];
}

if (focussed) {
UITabBarController *tabController = [(TiUITabGroup *)[self view] tabController];
NSUInteger blessedController = [tabController selectedIndex];
Expand Down
28 changes: 28 additions & 0 deletions tests/Resources/ti.ui.tabgroup.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,34 @@ describe('Titanium.UI.TabGroup', function () {
tabGroup.addTab(tab);
tabGroup.open();
});

it('blur event on opening new window', finish => {
const win = Ti.UI.createWindow();
tabGroup = Ti.UI.createTabGroup();
const tab = Ti.UI.createTab({
title: 'Tab',
window: win
});

function openNewWindow() {
setTimeout(() => {
tabGroup.addEventListener('blur', done);
const newWin = Ti.UI.createWindow();
newWin.open();
}, 1);
}

function done() {
tabGroup.removeEventListener('open', openNewWindow);
tabGroup.removeEventListener('blur', done);
finish();
}

tabGroup.addEventListener('focus', openNewWindow);

tabGroup.addTab(tab);
tabGroup.open();
});
});

it.windowsBroken('#setActiveTab()', finish => {
Expand Down