fix(ios): typing attributes clearing on keystrokes - #773
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses an iOS TextKit edge case where typingAttributes can be cleared between a selection change (especially via tap) and the next keystroke, causing newly typed text to lose formatting. The fix preserves typing attributes by re-running typing-attributes management immediately before character insertion.
Changes:
- Track the last
onlySelectionChangedvalue used during typing-attributes management and expose a method to re-run it. - Re-run recent typing-attributes management in
textView:shouldChangeTextInRange:right before insertion to prevent cleared attributes. - Minor comment updates related to the new behavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| ios/inputAttributesManager/InputAttributesManager.mm | Stores the most recent onlySelectionChanged flag and adds a method to re-run typing-attribute management. |
| ios/inputAttributesManager/InputAttributesManager.h | Exposes repeatRecentTypingAttributesManagement for callers. |
| ios/EnrichedTextInputView.mm | Calls the repeat method before text insertion to prevent typing attributes from being cleared. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
I'm kinda shocked that we find such issue this late and there was no community report about it. Could you please try checkouting some much older version (ideally something from, say, April this year) to see if it is an actual issue we haven't addressed for this long, or a regression?
And regardless of the result, we definitely want some E2E for this case!
I've checked a commit from April and the issue is present there. I've also added e2e tests for that specific case. |
szydlovsky
left a comment
There was a problem hiding this comment.
Everything checks out for me now 👍
Summary
There was a bug when in some cases, between selection change and a keystroke, the typing attributes would get cleared, resulting in unstyled text. More info in the
Screenshots / Videossection.All iOS e2e tests pass.
Test Plan
Reproduce the flow from the attached videos, it should be fine now.
Screenshots / Videos
Before:
When changing the selection programmatically, via arrow keys, the typing attributes are correctly preserved
Screen.Recording.2026-08-14.at.11.22.08.mov
When using screen taps though, the typing attributes are not preserved resulting in the unstyled text, even though (in this case bold) was marked as active
Screen.Recording.2026-08-14.at.11.23.10.mov
After:
Typing attributes are correctly preserved whatever the selection change method
Screen.Recording.2026-08-14.at.11.09.03.mov
Compatibility
Checklist