Users discuss a minor UI quirk in Discourse where selecting text with a leading space before creating a link causes the space to be removed. Cardinalflyer reports the issue and shares a GIF demonstrating it. ondrej asks if manually adding a space fixes the appearance. Stephen explains that the toolbar intentionally trims whitespace from link selections to avoid messy formatting, and advises users to avoid selecting leading spaces. codinghorror agrees it’s not a bug but suggests a user-friendly enhancement: automatically restoring single leading or trailing spaces outside the anchor tag. Cardinalflyer confirms this would be ideal, noting the space should be placed outside the anchor to preserve clean HTML. Finally, vinothkannans links to a commit (580b289) that resolves the issue by detecting and restoring such spaces appropriately. The feature request was implemented to improve usability without compromising formatting integrity.
Here’s a small detail I keep bumping into: When adding a link to text in Post edit, if the selection includes the leading space that space will be swallowed in the process.
Testingthe leading space on Meta. Yep, it does the same. I try to be more careful but it keeps happening and might be a quick thing to fix…
In your example you select the leading space when creating the link. That’s not typical behavior. Try selecting the word without the space and the issue won’t occur.
It’s hard to call this a bug as the toolbar button is trimming white space from the selection because whitespace within anchors looks messy.
The latter is only happening because you’re selecting the leading space, don’t do that and the link presentation cleanup won’t hit you.
You are correct but a nice user convenience feature would be to detect this and fix it up for the user, if a single leading or trailing space is selected, put them back in the replacement.