Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-27500] Android DrawerLayout "open" event also fires "open" event of parent Window

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionInvalid
Resolution Date2020-01-14T23:49:09.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labelsandroid, drawerlayout, engTriage, event, open
ReporterArjan
AssigneeGary Mathews
Created2019-09-19T08:38:20.000+0000
Updated2020-01-15T07:50:46.000+0000

Description

When attaching the eventListener "open" to the drawer view, this also triggers the "open" eventListener of the parent window it has been added to. EDIT: it also happens with the close event. SDK: 8.1.1.GA Code example:

var win = Ti.UI.createWindow();

var leftView = Ti.UI.createView({ backgroundColor:'red' });
var centerView = Ti.UI.createView({ backgroundColor:'yellow' });
var rightView = Ti.UI.createView({ backgroundColor:'orange' });

var drawer = Ti.UI.Android.createDrawerLayout({
    leftView: leftView,
    centerView: centerView,
    rightView: rightView
});
var btn = Ti.UI.createButton({ title: 'RIGHT' });

btn.addEventListener('click', function() {
    drawer.toggleRight();
});

centerView.add(btn);

win.addEventListener('open', function(){
	
	console.log('window opened');	
	
    var activity = win.getActivity(),
        actionBar = activity.getActionBar();

    if (actionBar) {
        actionBar.displayHomeAsUp = true;
        actionBar.onHomeIconItemSelected = function() {
            drawer.toggleLeft();
        };
    }
});

drawer.addEventListener('open', function() {
	console.log('drawer opened');	
});

drawer.addEventListener('close', function() {
	console.log('drawer closed');	
});

win.add(drawer);
win.open();

Comments

  1. Sharif AbuDarda 2019-10-25

    Hello [~arif], I was able to reproduce the issue in SDK 8.2.0.GA. I will forward this to the engineering team to investigate. Thanks.
  2. Gary Mathews 2020-01-14

    Closing as invalid, this is not a bug. bubbleParent is set to true by default, you must set it to false to prevent events from bubbling up to parent views.
       Ti.UI.Android.createDrawerLayout({
           bubbleParent: false,
           ...
       
  3. Arjan 2020-01-15

    Nice one, can be that simple sometimes :-) Thanks for checking this!

JSON Source