Fixed Mastodon social account field mangling input while typing#28255
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughThe SocialAccounts component now tracks the focused input via a focusedKey state and prevents the settings-to-UI sync from updating a field while it's focused. A handleSocialBlur clears focusedKey and, if validation (getSocialValidationError) passes, normalizes the value with normalizeSocialInput and writes the normalized displayValue back into urls. Each TextField sets focusedKey on focus and calls handleSocialBlur on blur. Acceptance tests were updated/added to verify no mid-typing rewrites, canonicalization only on blur, and acceptance of federated Mastodon URLs. Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
1dbf3c1 to
dd6f1ba
Compare
…#27785) The Mastodon field in Settings -> Social Accounts rewrote the input mid-typing, making it impossible to enter handles like @username@instance.tld. Typing "@murat@muratcorlu.com" got reordered to "https://muratcorlu.com/@murat" before the user finished, because the field was canonicalized on every keystroke and a partial TLD (e.g. "muratcorlu.co") already validates as an FQDN. The root cause was the resync effect: each keystroke calls updateSetting, which changes the stored handle and triggers the effect to overwrite the visible field with the canonical display value. For prefix-append platforms (Instagram etc.) the cursor stays at the end so typing keeps working, but the Mastodon handle form reorders tokens, corrupting in-progress input. Keep the raw text while the field is focused and only canonicalize on blur (and only when valid, so invalid input is left as typed with its error). This is the flow the existing testUrlValidation helper already exercises (fill -> blur -> expect canonical), so all platforms keep their canonicalized display value once editing finishes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
dd6f1ba to
6faa59d
Compare
Fixes #27785
Problem
The Mastodon field in Settings → Social Accounts rewrites the input while you type, making it impossible to enter handles like
@username@instance.tld(or federated URLs such ashttps://fedi.pub/@murat@muratcorlu.com).Typing
@murat@muratcorlu.comcharacter-by-character gets reordered tohttps://muratcorlu.com/@muratbefore you finish — the moment you reach@murat@muratcorlu.co,muratcorlu.coalready validates as an FQDN, so the field is canonicalized early, the.comis dropped and the cursor jumps.Root cause
It's not the regex — it's when normalization runs. Every keystroke calls
updateSetting, which changes the stored handle and triggers the resyncuseEffectto overwrite the visible field with the canonical display value.For prefix-append platforms (Instagram, etc.) the canonical form is
prefix + raw tail, so the cursor stays at the end and typing keeps working. But the Mastodon handle form reorders tokens (@user@instance→https://instance/@user), which corrupts in-progress input.Fix
Keep the user's raw text while the field is focused, and canonicalize once on blur — and only when the value is valid, so invalid input is left as typed with its error rather than reverted.
This is the flow the existing
testUrlValidationhelper already exercises (fill → blur → expect canonical), so every platform keeps its canonicalized display value once editing finishes.Tests
https://muratcorlu.com/@murat) and passes with the fix.🤖 Generated with Claude Code