Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus input on popup #822

Closed
mlynch opened this issue Mar 18, 2014 · 7 comments
Closed

Focus input on popup #822

mlynch opened this issue Mar 18, 2014 · 7 comments
Assignees

Comments

@mlynch
Copy link
Member

@mlynch mlynch commented Mar 18, 2014

Some popups should focus their inputs first. Should test this to make sure it works well on iOS though.

@mlynch mlynch added this to the 1.0.0-beta.2 milestone Mar 18, 2014
@mlynch mlynch self-assigned this Mar 18, 2014
@mlynch mlynch assigned ajoslin and unassigned mlynch Apr 29, 2014
@adamdbradley adamdbradley added this to the 1.0.0-beta.3 milestone Apr 30, 2014
@adamdbradley adamdbradley removed this from the 1.0.0-beta.2 milestone Apr 30, 2014
@calendee
Copy link

@calendee calendee commented May 30, 2014

Popups already focus their inputs first. However, there is a bug with this. The popup always focuses the LAST input element. It should really focus the first.

Forum : http://forum.ionicframework.com/t/popup-with-multiple-text-input-fields-always-focuses-on-2nd-input/4956/2
Sample : http://codepen.io/calendee/pen/duvsl?editors=101

PR coming in a few minutes.

@michaelnatkin
Copy link

@michaelnatkin michaelnatkin commented Jul 8, 2014

I find that this works great on web, but not on iOS... the code runs, but the input doesn't focus nor does the keyboard open up.

@calendee
Copy link

@calendee calendee commented Jul 10, 2014

@michaelnatkin : In your config.xml, make sure you have this setting:

<preference name="KeyboardDisplayRequiresUserAction" value="false" />

iOS will not allow a field to get focus and keyboard open unless this is set to false.

@michaelnatkin
Copy link

@michaelnatkin michaelnatkin commented Jul 10, 2014

@calendee OMG thank you!! Problem solved. Ionic team it would be nice to add that note to the ionicPopup doc.

@felquis
Copy link

@felquis felquis commented Jul 10, 2014

@calendee It work on iOS but this doesn't work on Android devices. Or there's something that I forgot?

@josephfrazier
Copy link

@josephfrazier josephfrazier commented Aug 10, 2014

@felquis, I had the same problem. After looking at this issue and #1176, I eventually found 49a2956, and I was able to fix my application by using a template with an autofocused input:

diff --git a/www/js/app.js b/www/js/app.js
index 8e7afcd..1131dfb 100644
--- a/www/js/app.js
+++ b/www/js/app.js
@@ -57,6 +57,7 @@ angular.module('todo', ['ionic'])
   $scope.newProject = function() {
     $ionicPopup.prompt({
       title: 'Project name',
+      template: '<input autofocus>'
     })
     .then(createProject)
   };

@a-legrand
Copy link

@a-legrand a-legrand commented May 4, 2016

I had to add this template string to my prompt in order to have autofocus

template: '<input ng-model="data.response" type="text" placeholder="{{ placeHolder }}" autofocus>'

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants