Doesn't work on iOS when nesting the elements within the label element
See original GitHub issueIt doesn’t work properly on iOS when nesting the elements within the label element.
This is the code
<label for="text-field">
From <span aria-hidden="true">*</span>
<input id="text-field" type="text" class="" placeholder="Departure airport" value="" list="airports" required aria-required="true">
<datalist id="airports" title="Choose an aiport">
<option value="Bologna, Guglielmo Marconi [BLQ] (ITALIA)">
<option value="Dubai, Al Maktoum Intl [DWC] (EMIRATI ARABI)">
<option value="Roma, Fiumicino [FCO] (ITALIA)">
<option value="New York Ny, John F Kennedy Intl [JFK] (STATI UNITI)">
<option value="Parigi, Charles De Gaulle [CDG] (FRANCIA)">
<option value="Berlino, Schoenefeld [SXF] (GERMANIA)">
<option value="Londra, Heathrow [LHR] (REGNO UNITO)">
</datalist>
</label>
I noticed that the select appears behind the keyboard, but if I put the datalist
out of label
it works.
Ok I tried to modify the markup also on the demo page and I confirm you that if datalist
is inside label
(and for my needs I have to do in this way), it doesn’t work.
Any suggestions?
JS Bin: https://output.jsbin.com/solopuq
_Originally posted by @acespace90 in https://github.com/mfranzke/datalist-polyfill/issues/43#issuecomment-431312871_
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Should I put input elements inside a label element?
Nesting the input inside the label preserves the maximum clickable area, giving maximum accessibility even for users that struggle with precise mouse or...
Read more >The Label element - HTML: HyperText Markup Language | MDN
To explicitly associate a <label> element with an <input> element, you first need to add the id attribute to the <input> element.
Read more >Common Accessibility Element Pitfalls and How to Avoid Them
An interesting issue involving nesting accessibility elements. You can find examples of the concepts discussed in this post (and much more) ...
Read more >Trying to nest an input element within a label element but not ...
Tell us what's happening: I was able to add the <input> box on the same line with the label. But my code doesn't...
Read more >HTML Inputs and Labels: A Love Story | CSS-Tricks
Each separate input element should only be paired with one label. And a label should only be ... Don't add elements like headings...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@acespace90, what I meant by my previous post was that the
label
shouldn’t include thedatalist
element in general (and from my perspective even also it doesn’t need to includeinput
elements, but that’s another discussion).Even on the „simple“ solution (and not using my polyfill at all) provided within the W3C specs to wrap the
option
elements within thedatalist
by aselect
you would face the same issue that you’ve reported on iOS - so this is what I wanted to reflect by providing their HTML code within that JSbin: https://jsbin.com/fegojipiqi/1/edit?html The reason why is that „interactive content“ shouldn’t be placed intolabel
elements, compare to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label#Interactive_contentThis would be a working JSBin with the
datalist
outside of thelabel
element: https://jsbin.com/cufelutulo/edit?htmlMentioned the aspect of not to include the
datalist
within thelabel
within thereadme
file.