Skip to content

fix(iOS): Text replacement and autocorrect attributes re-stamping - #888

Merged
szydlovsky merged 1 commit into
mainfrom
@szydlovsky/fix-wrong-attributes-restamping
Nov 27, 2026
Merged

szydlovsky merged 1 commit into
mainfrom
@szydlovsky/fix-wrong-attributes-restamping

Conversation

@szydlovsky

@szydlovsky szydlovsky commented Nov 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

An iOS fix a while ago made all:

  • autocorrect
  • spell check menu
  • and other text composing helpers

re-stamp attributes after they're done so that we don't lose formatting.

However it had a few issues;

  • it could go over too broad of a range resulting in more than just affected text gaining new formatting
  • it extended attributes we don't want spreading (links, mentions) - it is a blocker for the following PR: feat: add removeInvalidMentionContent prop #858 (comment)
  • it accidentally properly extended attributes when replacing range of characters (but it wasn't meant to be doing this)

The fix addresses all three issues:

  • we calculate precise range to re-stamp
  • we don't just blindly copy attributes; only our custom ones are grabbed and the ones that are non extensible (links, mentions, images) are skipped
  • the re-stamping now doesn't fix the attributes when user manually replaces a range of characters - now it's done independently via existing attributesManager methods only when we're sure no autocorrects/spellchecks are in play

Test Plan

  • try replacing a bold word with a letter - it should be bold
  • if you try replacing a partially bold word with a letter it will be plain (bold didn't span the whole selection)
  • autocorrect/spellcheck/predictive typing should all keep formatting
  • mentions/links can't be extended by selecting them as a whole and typing something

Screenshots / Videos

Screen.Recording.2026-11-27.at.15.14.47.mov

Compatibility

OS Implemented
iOS ✅
Android ❌
Web ❌

Checklist

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

@szydlovsky
szydlovsky requested a review from exploIF November 27, 2026 14:11
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 8d1a0bc and 14fd960.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • No new commits to review - use @coderabbitai full review for a full pass

No actionable comments were generated in the recent review.

Walkthrough

The iOS text input now captures eligible attributes for autocorrect and predictive replacements at a collapsed caret, extends typing attributes from selected text for nonempty replacements, and restamps captured attributes only within the recorded replacement range clipped to text storage.

Changes: iOS replacement attribute handling

Layer / File(s) Summary
Typing attribute restoration API
ios/inputAttributesManager/InputAttributesManager.h, ios/inputAttributesManager/InputAttributesManager.mm
InputAttributesManager adds extendTypingAttributesFromReplacedRange:. It restores eligible inline styles from an in-bounds range into a copy of the current typing attributes.
Replacement attribute capture and restamping
ios/EnrichedTextInputView.mm
The view records the replacement range and selectively captures attributes for nonempty replacements at a collapsed caret. For selection replacements, it extends typing attributes from the replaced range. Restamping uses the recorded range clipped to text storage bounds.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • software-mansion/react-native-enriched-html#855 — The issue concerns mention attributes during iOS typing or autocorrect. This change skips non-extensible attributes such as mentions during capture, but the summaries do not confirm that it fixes mention stripping.

Suggested reviewers: kacperzolkiewski

Merge Risk: Minimal · previous review 8d1a0

This change narrows iOS attribute re-stamping after autocorrect and spell-check, so links and mentions no longer spread. No concrete merge-blocking risk was found. Run the author's manual formatting checks on a device before release.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the iOS scope and the re-stamping of text replacement and autocorrect attributes, which matches the changeset. It is specific, and a teammate scanning history would understand the main…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description states the PR fixes iOS autocorrect, spell-check, and predictive text attribute re-stamping. It names the three issues addressed: over-broad re-stamping range, links and mentions sprea…
Full details: Title check

Explanation

The title names the iOS scope and the re-stamping of text replacement and autocorrect attributes, which matches the changeset. It is specific, and a teammate scanning history would understand the main change from it.

Full details: Description check

Explanation

The description states the PR fixes iOS autocorrect, spell-check, and predictive text attribute re-stamping. It names the three issues addressed: over-broad re-stamping range, links and mentions spreading, and attributes extending on manual range replacement. It also gives a test plan and platform compatibility table. The description matches the changeset, which adds range-precise re-stamping and extendTypingAttributesFromReplacedRange in the iOS files.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 7190229 and 8d1a0bc.

Files selected for processing: 3

  • ios/EnrichedTextInputView.mm
  • ios/inputAttributesManager/InputAttributesManager.h
  • ios/inputAttributesManager/InputAttributesManager.mm

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@szydlovsky
szydlovsky force-pushed the @szydlovsky/fix-wrong-attributes-restamping branch from 8d1a0bc to 14fd960 Compare November 27, 2026 14:55
@szydlovsky
szydlovsky merged commit 8fadac6 into main Nov 27, 2026
9 checks passed
@szydlovsky
szydlovsky deleted the @szydlovsky/fix-wrong-attributes-restamping branch November 27, 2026 15:36
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.

2 participants