datalist-polyfill icon indicating copy to clipboard operation
datalist-polyfill copied to clipboard

Layout issue when datalist is not a sibling

Open nsaunders opened this issue 5 years ago • 5 comments

Here's a strange one!

While testing in Safari 12.0.3, I noticed that when the datalist element is moved somewhere that it is not a sibling of the corresponding input, the select list hosting the suggestions is not rendered in the correct place:

https://codepen.io/anon/pen/VRpGOM

image

nsaunders avatar Mar 07 '19 16:03 nsaunders

@nicholassaunders, you're right - actually, there might be other constellations as well that would prevent easily positioning the datalist elements emulating select according to the inputs position easily, but implementing a solution that would fulfill all of those quite nicely might be a little bit more complicated, so regarding keeping the polyfill simple and "clean" I wanted to only officially support the general construct of the datalist being a direct follower of the input element.

But still there might be a simple solution for this problem, if somebody might come up with one, I'd be more than happy ! ;-)

mfranzke avatar Mar 07 '19 16:03 mfranzke

@mfranzke, thanks for the lightning-fast response. It's definitely a low-priority issue, easily solved in markup, as you pointed out. Still, I would like to revisit when time permits because I could imagine a scenario, particularly in the context of a single-page app, where the same datalist element is reused across multiple inputs and/or rendered in a different area of the app. I hope it's OK to keep the issue open as a reminder... If not, I suppose we could just call it an invalid use case and close the issue. Whatever makes sense to you!

nsaunders avatar Mar 07 '19 16:03 nsaunders

Makes sense, I even also see your use case. But I assume that it might be a little bit more complicated to achieve the polyfill currently expects that structure for simplicity. Let's see, probably something nice pops up as a beautiful and simple solution for that.

And I don't mind leaving it open.

mfranzke avatar Mar 07 '19 16:03 mfranzke

Probably popper.js might be a solution (optionally to include/support) for constellations like this. I'll have to investigate further.

mfranzke avatar Mar 16 '19 14:03 mfranzke

I'd like to add that I have a use case where a single datalist is used for several list inputs. I presume this would also be broken? It's a long datalist, so I don't want to duplicate it a few dozen times.

droundy avatar Aug 18 '20 02:08 droundy