laviastar / iscroll-js

Automatically exported from code.google.com/p/iscroll-js
MIT License
2 stars 2 forks source link

textfield.focus() fails after initiating iScroll #32

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add a textarea element outside of the scrollable area (I know form elements 
don't work well with CSS animation).
2. Add an iScroll object to a page.
3. Try calling .focus() function on that textfield element to automatically 
focus that element and bring up the keyboard.

What is the expected output? What do you see instead?

The textarea should be focused and the keyboard should be brought up so the 
user can start typing into the textarea immediately. Instead, the text area 
doesn't get focused.

What version of the product are you using? On what operating system?

iScroll 3.7.1 and tested on iPhone 3.1.3 and Android 2.2.

Please provide any additional information below.

Here's a code example.

<div>
  <form>
    <textarea id="ta"></textarea>
  </form>
  <div id="scroller-wrapper">
    <div id="scroller">stuff</div>
  </div>
</div>

<script>
  myScroller = new iScroller('scroller');
  .
  .
  .
  obj = document.getElementById('ta');
  obj.focus(); 
</script>

Here's the mobile web site i'm working on, which a code similar to the above 
have been deployed to and the defect can be observed.

http://stage.m.mindbloom.com

id/pw:
charles@mindbloom.com/12

To get to where the issue happens, go to actions -> click All from header -> 
click one of the actions -> click "edit entry" or "add entry" from one of the 
journal entry bubbles.

Original issue reported on code.google.com by charles%...@gtempaccount.com on 20 Oct 2010 at 11:46

GoogleCodeExporter commented 9 years ago
The website I've provided above may not work right now as I'm editing it pretty 
heavily. It's possible that I'll just not use iScroll on this site for good.

Original comment by charles%...@gtempaccount.com on 21 Oct 2010 at 11:28

GoogleCodeExporter commented 9 years ago
Well, I found out that if .focus() function is called by a fake event (like the 
one in touchEnd in iScroll line 335), it doesn't bring the keyboard up even 
though the function is triggered. It's likely the mobile browser bug. There 
really isn't a workaround for this because the fake event is necessary for the 
custom touch events to work. It seems like the keyboard only comes up if it is 
triggered by a genuine click event. You may close this ticket as it isn't 
iScroll's fault.

Original comment by charles%...@gtempaccount.com on 25 Oct 2010 at 9:44

GoogleCodeExporter commented 9 years ago

Original comment by mat...@gmail.com on 25 Oct 2010 at 9:47