-
Notifications
You must be signed in to change notification settings - Fork 51
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
iOS: Show a fully functional numeric keyboard ( input[type=number] ) #16
Conversation
@georgealways One side effect of this change is that Chrome will display decimal values using comma as a separator instead of a period depending of your OS regional settings (I think ?). My workaround for now is to convert the inputs back to type=text by calling
everywhere I add new controllers in my code. But every demo on the web that use lil-gui will always show me coma separated values. Do you have a better solution to my workaround? Let me know if you need more info or if you're interested by a PR. Thanks |
I see... It looks like you might be able to add a |
Unfortunately adding |
Ah, bummer—thanks for trying that out though. So I'm not sure what to do here yet. One of the main goals for lil-gui was being easier to use on mobile than dat-gui was. Setting this back to type=text would add an extra tap to every interaction with the number input. Hopefully the snippet above can get you by for now. Let's leave this open if others want to chime in. |
I'm using the slider most of the time to interact with numbers, especially when I'm debugging on mobile.
Well it kind of works for my own projects, but more importantly, this means that everyone browsing the three.js examples (or any other demos with lil-gui) using Chrome from a country where a comma is used as decimal mark, will get badly formatted decimal values... Unfortunately until Chrome adds a way to chose which separator to use for decimals (like Safari or Firefox), I would recommend using an input text instead as the default for displaying numerical values. But I can think of two workarounds that might solve the issue on mobile:
Since Chrome on iOS is running Webkit it won't be an issue to set the type to number. Let me know what you think and if you're interested in a PR? |
I was hoping to avoid
<input type="number">
forNumberController
. We're not using any of its stepping / clamping, the alt messages it shows on invalid entries are distracting, and there's a fair bit of CSS required to get rid of the native styles.Still, it's important that mobile users get a numeric keyboard by default when focusing a number field. Up until now I had hoped to accomplish that with
<input type="text" inputmode="decimal">
. That's enough on Android, but naturally iOS must be difficult.The iOS keyboard doesn't have a negative symbol with
inputmode="decimal"
. Strangely, it's not required. From the MDN docs on inputmode decimal:The only way to default to a fully functional numeric keyboard on iOS is with
<input type="number">
. I'm not excited about changing something foundational like this, but so far I haven't been able to distinguish between the two input types. I wish it wasn't necessary, but I think the change is justified: iPhones are popular.