Skip to content

Commit

Permalink
fix(ios): fire blur event when TabGroup focus is removed (#12207)
Browse files Browse the repository at this point in the history
Fixes TIMOB-28111
  • Loading branch information
vijaysingh-axway committed Nov 5, 2020
1 parent 7ac871c commit 5fa704d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
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

0 comments on commit 5fa704d

Please sign in to comment.