Safari: Strips extraneous return char when pasting text in single-line text entry field

Posted by Pierre Igot in: Macintosh
May 14th, 2005 • 5:11 am

This is one of these small enhancements that don’t get mentioned often enough.

For a long time, when I was filling out Web forms in Safari, I had to deal with the fact that, when I had copied text from another application and tried to paste it into a single-line text entry field in the Web form, if I had accidentally included the return character at the end of the line of text in the selection before I had copied it to the Clipboard, then when I pasted the contents of the Clipboard into the single-line text entry field, Safari would also insert the return character at the end of the line of text and make the single-line text field “scroll” down (even though it doesn’t have a vertical scroll bar, since it’s a single-line text entry field).

The end effect would be that, after pasting the contents of the Clipboard into the field, the field would look like it was still empty, because Safari would actually be showing the second line of text after the carriage return, which indeed would be empty. It was weird. You could still fix the problem by simply pressing the Delete key once after pasting the text, which would delete the return character and put the focus back on the first — and only — line of text in the field. But it was weird nonetheless.

Thankfully, at some point Apple realized the problem and fixed it. I don’t remember exactly when. It might have been in Safari 1.2 — or Safari 1.3. But they did fix it, in a smart way, by simply stripping the return character altogether when the user pastes a line of text followed by a return character into a single-line text entry field in a Web form.

What happens if you copy more than one paragraph of text — i.e. several lines of text followed by return characters — and then paste them into a single-line text entry field in a Web form? Well, Safari simply keeps the first line of text only and gets rid of all the rest. It makes sense. And it’s one of these small details that give you a sense that, unlike other software companies that shall remain nameless, Apple does bother to try and use its software in real-world situations and see what happens.


Comments are closed.

Leave a Reply

Comments are closed.