Skip to content

[Bug Fix][Fabric] Fix onChangeText firing twice when first typing in TextInput #14788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

HariniMalothu17
Copy link
Contributor

@HariniMalothu17 HariniMalothu17 commented Jun 17, 2025

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

Why

In Fabric TextInput, when a user types a single character, the onChangeText callback was being triggered twice instead of once. This was inconsistent with Paper TextInput behavior and could cause issues in applications that rely on accurate change event counts.

Resolves [https://github.com//issues/12780 ]

What

The new solution uses text-based deduplication - it only emits onChange when the current text differs from the last text for which onChange was emitted. This prevents duplicate onChange events while preserving all expected onChange behavior.

Screenshots

(image)

Testing

E2E test ran succesfully

Changelog

yes

Add a brief summary of the change to use in the release notes for the next release.

Microsoft Reviewers: Open in CodeFlow

@HariniMalothu17 HariniMalothu17 marked this pull request as ready for review June 17, 2025 12:00
@HariniMalothu17 HariniMalothu17 requested a review from a team as a code owner June 17, 2025 12:00
@HariniMalothu17 HariniMalothu17 changed the title [Fabric] Fix onChangeText firing twice when first typing in TextInput [Bug Fix][Fabric] Fix onChangeText firing twice when first typing in TextInput Jun 17, 2025
onChangeArgs.eventCount = ++m_nativeEventCount;
emitter->onChange(onChangeArgs);
auto currentText = GetTextFromRichEdit();
if (currentText != m_lastOnChangeText) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like a pretty expensive check. If there was a very large set of text in the textiput, this comparison would get relatively expensive. Is there not some code flow way of determining that the event is not needed?

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