🐛 Fixed Mastodon social account field mangling input while typing (#28255)
fixes https://github.com/TryGhost/Ghost/issues/27785 The Mastodon field in Settings → Social Accounts rewrote the input while the user was still typing, making handles like @username@instance.tld and federated URLs like https://fedi.pub/@user@instance.com impossible to enter. The field would reorder mid-typing — e.g. once "@user@instance.co" became a valid FQDN, the value was canonicalised to "https://instance.co/@user" before the user finished typing ".com", dropping characters and jumping the cursor. The cause was not the validation regex but when normalisation ran. Every keystroke calls updateSetting, which changes the stored handle and triggers the resync effect to overwrite the visible field with the canonical display value. For platforms whose canonical form is a prefix plus the raw tail (Instagram, etc.) the cursor stays at the end and typing is unaffected, but the Mastodon handle form reorders tokens (@user@instance → https://instance/@user), which corrupts in-progress input. The fix tracks which field is focused and leaves the user's raw text untouched while they are editing it, canonicalising once on blur and only when the value is valid — invalid input is left as typed with its error rather than reverted. This matches the behaviour the existing testUrlValidation helper already relied on (fill → blur → expect canonical), so every platform keeps its canonicalised display value once editing finishes. Covered by acceptance tests that type a handle character-by-character (asserting the field is not rewritten mid-typing, then canonicalises on blur) and that a federated Mastodon URL can be entered without error. One existing Instagram test was updated to blur before asserting the canonical value, since it previously relied on canonicalise-while- focused.
H
Hannah Wolfe committed
8dc8fbf435bb71526c9030dd74d931e840e90a6d
Parent: 5a84731
Committed by GitHub <noreply@github.com>
on 5/29/2026, 3:57:26 PM