Skip to content

fix(android): keyboard issues in BottomNavigation and androidback issue - #14537

Open
m1ga wants to merge 8 commits into
mainfrom
androidFixBottomNavigation
Open

fix(android): keyboard issues in BottomNavigation and androidback issue#14537
m1ga wants to merge 8 commits into
mainfrom
androidFixBottomNavigation

Conversation

@m1ga

@m1ga m1ga commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Fixes: #14536

  1. TiEdgeToEdgeHelper.java — when the helper absorbs the keyboard by padding the content frame, it now consumes the IME inset and caps the bottom of navigationBars()/captionBar() before the insets propagate to descendants (left/top/right are preserved for the TabLayout status-bar case). This stops Material's BottomNavigationView from padding itself a second time with the keyboard height.
  2. TiUIBottomNavigationTabGroup.java — the view pager's bottom-offset update is posted after the current layout pass, eliminating the requestLayout() improperly called warning.
  3. IME Guard: Because the guard sits in handleBackNavigation(), it covers all three entry points: the predictive-back OnBackInvokedCallback (the path that caused the bug on API 33+ with enableOnBackInvokedCallback="true"), legacy onBackPressed(), and subclasses that call it. I deliberately used root window insets rather than the existing keyboardVisible field, since that field is only updated when the app has a keyboardframechanged listener.
  4. androidback now fires on the activity proxy when it has listeners (the legacy tabGroup.activity / win.activity.addEventListener('androidback', ...) pattern), and only falls back to the window proxy otherwise — exactly the priority the old KEYCODE_BACK branch in dispatchKeyEvent() used before predictive back made it dead code on API 33+.

Test code

const win1 = Ti.UI.createWindow({
	backgroundColor: "#fff"
});
const win2 = Ti.UI.createWindow({});
const tab1 = Ti.UI.createTab({
	window: win1,
	title: 'Tab 1',
	icon: '/images/appicon.png'
});
const tab2 = Ti.UI.createTab({
	window: win2,
	title: 'Tab 2',
	icon: '/images/appicon.png'
});

var search = Ti.UI.Android.createSearchView({
	hintText: "Table Search"
});

const tbl = Ti.UI.createTableView({
	search: search,
	data: [{
		title: 'Apples'
	}, {
		title: 'Bananas'
	}, {
		title: 'Carrots'
	}, {
		title: 'Potatoes'
	}]
});
win2.add(tbl);

const tf = Ti.UI.createTextField({
	width: 200,
	backgroundColor: '#fff',
	borderColor: '#000',
});

const sv = Ti.UI.createScrollView({
	contentHeight: Ti.UI.SIZE,
	height: Ti.UI.FILL,
	scrollType: "vertical",
	layout: "vertical"
})

sv.add(tf);

const btn = Ti.UI.createButton({
	title: "alert"
})
btn.addEventListener("click", function() {
	const view = Ti.UI.createView({
		height: 100
	});
	const tf = Ti.UI.createTextField({
		width: 100
	});
	view.add(tf);
	var dialog = Ti.UI.createAlertDialog({
		title: 'Enter text',
		androidView: view,
		buttonNames: ['OK']
	});
	dialog.show();
})
sv.add(btn);
win1.add(sv);

const tabgroup = Ti.UI.createTabGroup({
	tabs: [tab1, tab2],
	style: Ti.UI.Android.TABS_STYLE_BOTTOM_NAVIGATION,
	exitOnClose: false
});

tabgroup.open();
tabgroup.addEventListener("androidback", function() {
	var toast = Ti.UI.createNotification({
		message: "tabgroup back. closing in 2 seconds..."
	});
	toast.show();
	setTimeout(function() {
		tabgroup.close();
	}, 2000);
})
  • focus the textfield
  • open the alert and focus the textfield
  • use the back button in the textfield (only keyboard should hide)
  • try to close the app. toast should show up and wait for 2 seconds. It should put the app to the background and not show a blank screen/app logo

Fixed another app caused by the exitOnClose changes after checking a client app:
The app was calling a close() method in a previous window after opening a new controller. It was calling close() twice and was working like this in all other SDK versions besides this PR. It's fixed now and the app and test code below only closes one window, even you call close() twice:

const index = Ti.UI.createWindow({ backgroundColor: 'green', title: 'index' });

index.addEventListener('open', () => {
	Ti.API.info('TEST: index is open, wait 2 seconds...');
	setTimeout(() => {
		const main = Ti.UI.createWindow({ backgroundColor: 'red', title: 'main' });
		main.addEventListener('open', () => {
			Ti.API.info('TEST: main is open, closing index TWICE');
			index.exitOnClose = false;
			index.close();
			index.close();
			Ti.API.info('TEST: double close called');
		});
		main.open();
	}, 2000);
});

index.open();
  • run the app
  • wait a few seconds
  • it should show a red window and not close the whole app

@m1ga
m1ga requested a review from prashantsaini1 July 31, 2026 09:12
@m1ga m1ga changed the title fix(android): keyboard issues in BottomNavigation fix(android): keyboard issues in BottomNavigation and androidback issue Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android: BottomNavigation extends too much when textfield is focused

1 participant