iOS Safari URL copy & paste bug
Every now and then one stumbles upon a bug that turns out weirder than it initially looked. What I thought to be some JavaScript that blocked some pasting from working out appeared to be a Safari iOS bug.
So – what’s the bug? Well – turns out that iOS Safari refuses to paste a URL copied from its own share sheet into any HTML input field. It’s like it believes the URL isn’t valid input – like its an image or something.
Steps to reproduce
As a gif:
Or on the same JSBin or eg. Google do:
- Copy URL from share sheet
- Go to text input field in HTML – try to paste
- Find out you’re unsuccessful
- Try the URL input field
- Still no success
- Paste the URL into a random application, like Notes.app, and copy it again
- Try pasting it into one of the fields again – it works, right?
Why is it like this?
No idea.
I guess that there’s some kind of metadata added to the URL copied from Safari that tells application what’s in the clipboard and that Safari itself interprets that metadata as saying that the URL data isn’t valid text data – even for input fields of type “url”.
Copying the full URL from the address bar of Safari or a URL from a text source like Notes.app doesn’t give the same error. Only place I’ve found that sets the metadata that Safari then misinterprets is the “Copy” button of the Safari share sheet itself.
Is there a workaround?
Not that I know of. Except for not asking your users to paste URL:s into fields like this in iOS Safari. Which eg. makes the WebMentions field I myself have on this very blog a bit hard to achieve.
Would love to hear if anyone has had any experience with this themselves or found solutions to it.
Ping me on @voxpelli or WebMention me on this post.