# iOS set focus on input

**URL:** <https://forum.bubble.io/t/ios-set-focus-on-input/73225>\
**Category:** Mobile\
**Created:** [December 3, 2019, 1:00pm UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225 "2019-12-03T13:00:42Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![cx1](https://avatars.discourse-cdn.com/v4/letter/c/eb8c5e/32.png) [@cx1](https://forum.bubble.io/u/cx1)\
**Post date:** [December 3, 2019, 1:00pm UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225/1 "2019-12-03T13:00:42Z")

</div>

Hi there,

In my workflow, I use the block set focus on input. This works perfectly on my browser and android devices, but not on iOS. According to other forums Apple has an issue with that, but there are some workarounds to be done on the code. Does anyone know how to solve that via bubble?

Thanks,  
Gabriela

---

<div class="post-metadata">

**Author:** ![charly](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/charly/32/37000_2.png) [@charly](https://forum.bubble.io/u/charly)\
**Post date:** [December 3, 2019, 1:53pm UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225/2 "2019-12-03T13:53:22Z")

</div>

Hello Gabriela,

If I remember well, it is a matter of font size inside. With a 14px font, it will not focuse anymore (I think it should be equal or more than 12px so as not to zoom)

---

<div class="post-metadata">

**Author:** ![cx1](https://avatars.discourse-cdn.com/v4/letter/c/eb8c5e/32.png) [@cx1](https://forum.bubble.io/u/cx1)\
**Post date:** [December 4, 2019, 5:43pm UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225/3 "2019-12-04T17:43:15Z")

</div>

Hi, my problem is not with zoom. In the settings, i configured the app to not autozoom when clicked. The problem is the “focus on input” does not focus on iOS

---

<div class="post-metadata">

**Author:** ![georg](https://avatars.discourse-cdn.com/v4/letter/g/9f8e36/32.png) [@georg](https://forum.bubble.io/u/georg)\
**Post date:** [November 23, 2020, 10:06am UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225/4 "2020-11-23T10:06:44Z")

</div>

bump, any solution for this? I have the same issue…

---

<div class="post-metadata">

**Author:** ![aj11](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/aj11/32/118613_2.png) [@aj11](https://forum.bubble.io/u/aj11)\
**Post date:** [December 18, 2020, 9:38pm UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225/5 "2020-12-18T21:38:46Z")

</div>

bump, any fix for this?

---

<div class="post-metadata">

**Author:** ![guillaume2](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@guillaume2](https://forum.bubble.io/u/guillaume2)\
**Post date:** [December 12, 2021, 6:03am UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225/6 "2021-12-12T06:03:10Z")

</div>

bump, any fix for this?

---

<div class="post-metadata">

**Author:** ![ben29](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/ben29/32/102546_2.png) [@ben29](https://forum.bubble.io/u/ben29)\
**Post date:** [December 15, 2021, 9:28pm UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225/7 "2021-12-15T21:28:54Z")

</div>

Bump, any fix for this?

---

<div class="post-metadata">

**Author:** ![marca](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/marca/32/25404_2.png) [@marca](https://forum.bubble.io/u/marca)\
**Post date:** [January 24, 2022, 11:15pm UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225/8 "2022-01-24T23:15:54Z")

</div>

This is actually a limitation in mobile Safari, which deliberately prevents programmatic focusing before the user has interacted with the page.

For further reading on the subject, here’s a [stackoverflow thread](https://stackoverflow.com/questions/48547975/cant-set-focus-in-safari) and a [medium post](https://medium.com/@brunn/autofocus-in-ios-safari-458215514a5f).

---

<div class="post-metadata">

**Author:** ![chris19](https://avatars.discourse-cdn.com/v4/letter/c/ebca7d/32.png) [@chris19](https://forum.bubble.io/u/chris19)\
**Post date:** [January 25, 2022, 12:02am UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225/9 "2022-01-25T00:02:30Z")

</div>

Thanks, Marca for looking into my bug request. I’ve experienced this with the google chrome browser on iPhone does this also explain this? The link says that it works in chrome?

---

<div class="post-metadata">

**Author:** ![jdubbya](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jdubbya/32/246907_2.png) [@jdubbya](https://forum.bubble.io/u/jdubbya)\
**Post date:** [April 7, 2022, 7:54pm UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225/10 "2022-04-07T19:54:05Z")

</div>

FYI - Bubble is aware of this issue and there’s an existing feature request covering it.

Has anyone figured out a workaround for this scenario, in particular for “chat” pages? It’s not a great experience to have to tap the input field after every sent message. (As per @chris19 above, this also does not work in Chrome.)

---

<div class="post-metadata">

**Author:** ![oddddd](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/oddddd/32/158979_2.png) [@oddddd](https://forum.bubble.io/u/oddddd)\
**Post date:** [January 25, 2023, 8:46pm UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225/11 "2023-01-25T20:46:24Z")

</div>

Bump, any fix for this?

I’ve seen workarounds elsewhere (not Bubble related) using Vue.js and other things I don’t technically understand. Anyone found a way to integrate into a Bubble project?

---

<div class="post-metadata">

**Author:** ![oddddd](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/oddddd/32/158979_2.png) [@oddddd](https://forum.bubble.io/u/oddddd)\
**Post date:** [January 26, 2023, 5:21pm UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225/12 "2023-01-26T17:21:39Z")

</div>

> **EDIT:**  
> **Test it here**  
> **[https://setfocusioskeyboard.bubbleapps.io/version-test](https://setfocusioskeyboard.bubbleapps.io/version-test)**

So I think I’ve figured it out. I had to resort to using javascript, so I can almost guarantee that someone who actually knows javascript can make a more elegant version of this, but hey if it works it works.

HOW TO KEEP iOS KEYBOARD ACTIVE/FOCUSED ON A TEXT FIELD IN BUBBLE:  
To include javascript install the plugin called Toolbox. (I’m sure other javascript plugins work as well, have not checked)  
 ![Screenshot 2023-01-26 at 17.39.53](https://us1.discourse-cdn.com/bubble/original/3X/8/4/84e1697f80bbe5e70f1a573a375d6c7d96559138.jpeg)

Then to be able to connect javascript with bubble elements enable the ‘expose the option to add an ID attribute to HTML elements’ option in settings in the General tab.

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/f/b/fbbd337be0def599247f6da7eb4eba5d3afe46bf.png)

The problem I was trying to solve was for a user to be able to add several items into a database without losing the iOS keyboard after saving each item. I used an input form, a button, and a repeating group with a text element to display the data. (DB is called ‘Steps’, the DB field the user is adding to is called ‘Action’.) It looks like this:

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/4/b/4ba422a00b7eca642fed39e799672f875c1d4635.png)

Add an **ID Attribute** for both the input form and another for the button. Call them whatever you want. Example:

Input form id:  
 ![image](https://us1.discourse-cdn.com/bubble/original/3X/f/1/f1b1f95e0502774fef6d030d5d0370e8c2808993.png)  
Button id:  
 ![image](https://us1.discourse-cdn.com/bubble/original/3X/6/c/6c6d1317a7bfae9984c301496b22cac5ef7945f4.png)

Then in the button’s workflow add ‘Run Javascript’

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/f/d/fda1875facce0b1d80b92b4c149164e8ae4eff5d.jpeg)

The javascript code I used:

```
 var saveButton= document.getElementById("save_step");
 var textInput= document.getElementById("input_step");

saveButton.onclick = function() 
{if (textInput.value !="") 
  {textInput.value = ""; }
{
        textInput.focus()
    }
}

```

That’s it. Well almost. For whatever reason, it doesn’t work the first time the button is clicked, but does work on all subsequent clicks. Not wanting to explain this to my users I found a workaround:

Turn off visibility on page load for input form:  
 ![image](https://us1.discourse-cdn.com/bubble/original/3X/2/6/265cd9ac5b40d277fb4743ace7b90b52112eaff3.png)

Then have the user click the ‘save’ button in order to display the text field.

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/e/4/e4d2727310dddb1ed28a56c4fb34d9b5f3119e98.png)

Another workaround might work better in other apps, but in my case it really helps the UX feel native.

So there you have it. Hope this can be of use for more people.

---

<div class="post-metadata">

**Author:** ![oddddd](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/oddddd/32/158979_2.png) [@oddddd](https://forum.bubble.io/u/oddddd)\
**Post date:** [January 26, 2023, 5:53pm UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225/13 "2023-01-26T17:53:55Z")

</div>

For the last part to work well, consider adding ‘FieldName isn’t empty’ as a search constraint. Nobody wants to look at an empty field.

 ![image](https://us1.discourse-cdn.com/bubble/original/3X/2/2/22bd23e04e9186f9e908d7b01da50f606bc45d04.jpeg)

---

<div class="post-metadata">

**Author:** ![snowsnow](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@snowsnow](https://forum.bubble.io/u/snowsnow)\
**Post date:** [February 15, 2023, 11:36pm UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225/14 "2023-02-15T23:36:33Z")

</div>

@oddddd

I think the script works only from the second click because it gets activated only after the first click.

Try to run the script on page load. Then it will work the first time you click the Save button.

I did a similar thing on my app and it works at the first click.

---

<div class="post-metadata">

**Author:** ![oddddd](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/oddddd/32/158979_2.png) [@oddddd](https://forum.bubble.io/u/oddddd)\
**Post date:** [February 23, 2023, 4:18pm UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225/15 "2023-02-23T16:18:26Z")

</div>

@snowsnow

Thank you! That is way more elegant.

---

<div class="post-metadata">

**Author:** ![ramasuarez](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/ramasuarez/32/181820_2.png) [@ramasuarez](https://forum.bubble.io/u/ramasuarez)\
**Post date:** [June 13, 2023, 12:08pm UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225/16 "2023-06-13T12:08:15Z")

</div>

You saved me a lot of time. Thank you.

---

<div class="post-metadata">

**Author:** ![eagledev](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/eagledev/32/175826_2.png) [@eagledev](https://forum.bubble.io/u/eagledev)\
**Post date:** [July 17, 2023, 11:04am UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225/17 "2023-07-17T11:04:21Z")

</div>

@oddddd thank you man! this is very helpful!

---

<div class="post-metadata">

**Author:** ![davewliu](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@davewliu](https://forum.bubble.io/u/davewliu)\
**Post date:** [September 4, 2023, 10:26am UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225/18 "2023-09-04T10:26:59Z")

</div>

@oddddd @snowsnow @ramasuarez @eagledev did you guys have to change the javascript code that you ran on page load?

not sure why, but tried to add the same script on pageload but first click still doesn’t work (while second click does work).

many thanks!

---

<div class="post-metadata">

**Author:** ![snowsnow](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@snowsnow](https://forum.bubble.io/u/snowsnow)\
**Post date:** [September 4, 2023, 10:39am UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225/19 "2023-09-04T10:39:48Z")

</div>

@davewliu  
This plugin fixes the problem easily:  
[Open iOS keyboard (Apple iPhone) Plugin | Bubble](https://bubble.io/plugin/open-ios-keyboard-apple-iphone-1677488913660x259832469497053200#:~:text=This%20plugin%20allows%20you%20to%20do%20that.&text=You%20have%20a%20button%20that,in%20focus%2C%20ready%20to%20type).

---

<div class="post-metadata">

**Author:** ![davewliu](https://avatars.discourse-cdn.com/v4/letter/d/f14d63/32.png) [@davewliu](https://forum.bubble.io/u/davewliu)\
**Post date:** [September 5, 2023, 1:57am UTC](https://forum.bubble.io/t/ios-set-focus-on-input/73225/20 "2023-09-05T01:57:20Z")

</div>

thanks!

bought it, weirdly it doesn’t work for my app even after messing around for quite some time… although the demo works.

guessing it’s user error :-T will reach out to the plugin author for ideas

[Next page](https://forum.bubble.io/t/ios-set-focus-on-input/73225.md?page=2)
