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

input[type=date] with empty value shrunken height on mobile #23307

Closed
rixlabs opened this issue Aug 11, 2017 · 14 comments
Closed

input[type=date] with empty value shrunken height on mobile #23307

rixlabs opened this issue Aug 11, 2017 · 14 comments

Comments

@rixlabs
Copy link

rixlabs commented Aug 11, 2017

On iPad, an input of type date that doesn't have any initial value appear smaller until touched or a date selected.

I tested the same situation on Chrome for Android and there is working fine

Reduced test case here: http://jsfiddle.net/ctesyxxx/1/
Tested on: Safari for iPad , iOS 10.1.1

@ianbrandt
Copy link

ianbrandt commented Oct 5, 2017

@rixlabs Same here for both Chrome and Safari on iPhone.

Quick-and-dirty workaround (YMMV):

input[type="date"] {
	min-height: 2.5rem;
}

@rixlabs
Copy link
Author

rixlabs commented Oct 5, 2017

@ianbrandt I did exactly the same...

@ianbrandt
Copy link

ianbrandt commented Oct 6, 2017

Updated my workaround to also account for #18842:

input[type="text"],
input[type="email"],
input[type="date"] {
	height: 2.375rem;
}

So far tested on Safari and Chrome on iOS and macOS, and Edge on Windows 10.

(In case it's not obvious you'll want to add any other input types you use, e.g. "password", "url", etc.)

@jckh1234
Copy link

I found it not only shorten the but also move the input slightly lower when placing inside a div.

https://stackoverflow.com/questions/49932842/html5-input-type-date-not-vertical-align-property-in-mobile-browser-when-value-i

@parisiam
Copy link

I encountered exactly the same problem in ios 11 and bootstrap 4.1.2: the temporal fields shrink if no initial value is selected.
https://jsfiddle.net/parisiam/0teuo9dy/50/
Another solution is to combine the field inside an input group with an icon (a calendar for instance).
capture d ecran 2018-07-14 a 15 38 51

@pekanct
Copy link

pekanct commented Aug 11, 2018

My solution was:

<input type="text "placeholder="Select a date" onfocus="$(this).hide().next().attr('hidden',false).focus();"/>
<input type="datetime-local"  hidden="true">

@mdo
Copy link
Member

mdo commented Aug 11, 2018

This should’ve been solved in v4.1.3 when we added fixed heights to inputs.

@mdo mdo closed this as completed Aug 11, 2018
@maschad96
Copy link

@mdo , I see that the fixed height has been added and so that fixes the collapsing issue.. quick question though. Are you aware of any way to prevent the hidden value issue? Although the height is no longer collapsed, I am unable to see a pre-populated value on an input[type="date"] unless I first focus on it, then the value does show.

@rixlabs
Copy link
Author

rixlabs commented Aug 27, 2018

I've tested again with the last version and it is indeed fixed!

Check here : http://jsfiddle.net/7fxdt260/

Tested on: Safari for iPad , iOS 10.1.1

@hotsoft-desenv2
Copy link

@mdo I think it's not solved yet... I'm using the latest version but the problem still present....

@karlbeecken
Copy link

I still have the problem, but this works for me:
<input type="text "placeholder="Select a date onfocus="$(this).hide().next().attr('hidden',false).focus();"/> <input type="datetime-local" hidden="true">

@ysds ysds reopened this Jun 19, 2019
@ysds ysds mentioned this issue Jun 19, 2019
1 task
@XhmikosR XhmikosR added the v5 label Aug 1, 2019
@mdo
Copy link
Member

mdo commented Feb 3, 2020

@MartijnCuppens @ysds #28917 mentions the fixed height change, but I didn't see that in the diff. Bad cross-reference, or something I'm missing?

@MartijnCuppens
Copy link
Member

This demo is an example of v4-alpha, this seems to be fixed in the meantime:

Before:
image

After:
image

@winner
Copy link

winner commented Aug 8, 2020

My solution was:

<input type="text "placeholder="Select a date" onfocus="$(this).hide().next().attr('hidden',false).focus();"/>
<input type="datetime-local"  hidden="true">

I solved critical issue on the iphone with your solution.
Thanks very much!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

16 participants