Skip to content

fix(ios): typing attributes clearing on keystrokes - #773

Merged
hejsztynx merged 10 commits into
mainfrom
@ksienkiewicz/fix-ios-typing-attributes-desync
Aug 24, 2026
Merged

fix(ios): typing attributes clearing on keystrokes#773
hejsztynx merged 10 commits into
mainfrom
@ksienkiewicz/fix-ios-typing-attributes-desync

Conversation

@hejsztynx

@hejsztynx hejsztynx commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

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 / Videos section.

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

OS Implemented
iOS
Android
Web

Checklist

  • E2E tests are passing
  • Required E2E tests have been added (if applicable)

Copilot AI lite review requested due to automatic review settings August 14, 2026 09:24
@hejsztynx
hejsztynx marked this pull request as draft August 14, 2026 09:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 onlySelectionChanged value 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.

Comment thread ios/EnrichedTextInputView.mm Outdated
Comment thread ios/EnrichedTextInputView.mm Outdated
hejsztynx and others added 2 commits August 14, 2026 11:40
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@hejsztynx
hejsztynx marked this pull request as ready for review August 14, 2026 11:22
@hejsztynx
hejsztynx requested a review from szydlovsky August 20, 2026 13:12

@szydlovsky szydlovsky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Comment thread ios/inputAttributesManager/InputAttributesManager.mm Outdated
Comment thread ios/EnrichedTextInputView.mm Outdated
@hejsztynx

Copy link
Copy Markdown
Collaborator Author

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 szydlovsky left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything checks out for me now 👍

@hejsztynx
hejsztynx merged commit 08eed0e into main Aug 24, 2026
8 checks passed
@hejsztynx
hejsztynx deleted the @ksienkiewicz/fix-ios-typing-attributes-desync branch August 24, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants