Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-24138

Android: TextField/TextArea should not receive focus by default when a window is opened

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Release 7.3.0
    • Component/s: Android
    • Environment:
      • Titanium SDK version: 1.7.6 (11/22/11 14:11 194e8e6...)
      • Android 3.1
      • Lenovo Thinkpad Tablet
      • Windows XP SP3
    • Story Points:
      3
    • Sprint:
      2018 Sprint 13 SDK, 2018 Sprint 14 SDK

      Description

      Behavior

      It seems that "focus" event doesn't work well on Android and this behavior cause awful user experience. To see the issue, run the test case below.

      Scroll to the bottom, but don't touch text fields. You'll see in the console output that text field fired "focus" event and that keyboard has shown on the screen.

      Also, scroll to the bottom, click "Click me!" button to open new window. Then, click "Close me!" button. ScrollView should be scrolled up to the text field that has "focus" (gained by a bug described above!), which creates awful user experience because user needs to scroll back to where he was before opening new window (ScrollView should not scroll after returning from newly created window).

      Test case

      app.js

      var win = Ti.UI.createWindow({
      	backgroundColor: '#000',
      	modal: true,
      	navBarHidden: true,
      	layout: 'vertical'
      });
       
      function createItem() {
      	var view = Ti.UI.createView({
      		height: 100,
      		width: '100%',
      		layout: 'horizontal'
      	});
      	
      	var label = Ti.UI.createLabel({
      		text: 'Testing ...',
      		width: '50%'
      	});
      	
      	var checkbox = Ti.UI.createSwitch({
      		style: Ti.UI.Android.SWITCH_STYLE_CHECKBOX
      	});
      	
      	view.add(label);
      	view.add(checkbox);
      	
      	return view;
      }
       
      function createTextField() {
      	
      	var view = Ti.UI.createView({
      		height: 100,
      		width: '100%',
      		backgroundColor: '#0ff',
      		layout: 'horizontal'
      	});
      	
      	var label = Ti.UI.createLabel({
      		text: 'Text field ...',
      		width: '50%'
      	});
      	
      	var textField = Ti.UI.createTextField({
      		width: '30%'
      	});
      	
      	textField.addEventListener('focus', function() {
      		Ti.API.info('Focus fired');
      	});
      	
      	view.add(label);
      	view.add(textField);
      	
      	return view;
      }
       
      var scrollView = Ti.UI.createScrollView({
      	layout: 'vertical',
      	backgroundColor: '#f00',
      	showVerticalScrollIndicator: true,
      	height: '100%',
      	width: '100%',
      	contentHeight: 'auto',
      	contentWidth: 'auto',
      	top: 0
      });
       
      for (var m = 0; m < 3; ++m) {
      	for (var i = 0; i < 20; ++i) {
      		scrollView.add(createItem());
      	}
      	var view = createTextField();
      	scrollView.add(view);
      }
       
      for (var j = 0; j < 20; ++j) {
      	scrollView.add(createItem());
      }
       
      var button = Ti.UI.createButton({ title: 'Click me!' });
       
      button.addEventListener('click', function() {
      	var context = Ti.UI.createWindow({
      		backgroundColor: '#000',
      		modal: true,
      		navBarHidden: true,
      		layout: 'vertical'
      	});
      	
      	var closeButton = Ti.UI.createButton({ title: 'Close me!' });
      	
      	closeButton.addEventListener('click', function() {
      		context.close();
      	});
      	
      	context.add(closeButton);
      	
      	context.open();
      });
       
      scrollView.add(button);
       
      win.add(scrollView);
       
      Ti.API.info('App runnning ...');
       
      win.open();
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jquick Joshua Quick
                Reporter:
                goyalpankaj054@gmail.com Pankaj Goyal
                Reviewer:
                Gary Mathews
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-10274
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code