Skip to content

fix(0.81): replace RCTUISecureTextField #include hack with proper OOP subclass#2894

Merged
Saadnajmi merged 1 commit intomicrosoft:0.81-stablefrom
Saadnajmi:backport/fix-secure-textfield-0.81
Apr 8, 2026
Merged

fix(0.81): replace RCTUISecureTextField #include hack with proper OOP subclass#2894
Saadnajmi merged 1 commit intomicrosoft:0.81-stablefrom
Saadnajmi:backport/fix-secure-textfield-0.81

Conversation

@Saadnajmi
Copy link
Copy Markdown
Collaborator

@Saadnajmi Saadnajmi commented Apr 8, 2026

Summary

Backport of #2895 to 0.81-stable.

  • Replaces the fragile preprocessor #include .mm trick in RCTUISecureTextField with proper OOP inheritance
  • RCTUISecureTextField now subclasses RCTUITextField directly and overrides +cellClass to return RCTUISecureTextFieldCell : NSSecureTextFieldCell
  • Removes all RCT_SUBCLASS_SECURETEXTFIELD preprocessor conditionals from RCTUITextField.h/.mm
  • Updates isKindOfClass:[NSSecureTextField class] checks to [RCTUISecureTextField class] in both Paper and Fabric code paths

Motivation

The old approach #included the entire 734-line RCTUITextField.mm with a #define to swap class/superclass names — a preprocessor trick to work around a diamond inheritance problem. This caused duplicate-symbol linker errors on non-macOS SPM builds and was fragile and confusing.

Since NSSecureTextField's masking behavior lives entirely in NSSecureTextFieldCell, the proper fix is to subclass RCTUITextField and override just the cell class (~50 lines of duplicated cell code vs. 734 lines recompiled via include).

Test plan

  • macOS build succeeds (RCTUISecureTextField inherits all behavior from RCTUITextField)
  • Secure text fields still mask input on macOS (masking comes from NSSecureTextFieldCell)
  • iOS/visionOS SPM builds pass without duplicate symbols or excludes
  • No regressions in text input behavior

🤖 Generated with Claude Code

@Saadnajmi Saadnajmi requested a review from a team as a code owner April 8, 2026 04:49
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 8, 2026

⚠️ No Changeset found

Latest commit: 27986b9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@Saadnajmi Saadnajmi changed the title fix: replace RCTUISecureTextField #include hack with proper OOP subclass [0.81 backport] fix(0.81): replace RCTUISecureTextField #include hack with proper OOP subclass Apr 8, 2026
@Saadnajmi Saadnajmi force-pushed the backport/fix-secure-textfield-0.81 branch from 95dff69 to 262d0d6 Compare April 8, 2026 05:42
Copy link
Copy Markdown
Member

@tido64 tido64 left a comment

Choose a reason for hiding this comment

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

See comments in #2895

The old RCTUISecureTextField.m used `#include "../RCTUITextField.mm"` to
re-compile the entire implementation with RCT_SUBCLASS_SECURETEXTFIELD
defined. This caused duplicate symbol errors in SPM builds because both
files were compiled as separate translation units.

Replace with a proper OOP subclass: RCTUISecureTextField now inherits
from RCTUITextField and overrides only what differs (NSSecureTextFieldCell).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Saadnajmi Saadnajmi force-pushed the backport/fix-secure-textfield-0.81 branch from 262d0d6 to 27986b9 Compare April 8, 2026 17:11
@Saadnajmi Saadnajmi merged commit 1efe66b into microsoft:0.81-stable Apr 8, 2026
12 of 14 checks passed
@Saadnajmi Saadnajmi deleted the backport/fix-secure-textfield-0.81 branch April 8, 2026 18:15
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