Skip to content

fix(android): attach missing events#53

Merged
enahum merged 1 commit into
masterfrom
attachAttributes
May 9, 2026
Merged

fix(android): attach missing events#53
enahum merged 1 commit into
masterfrom
attachAttributes

Conversation

@enahum
Copy link
Copy Markdown
Contributor

@enahum enahum commented May 9, 2026

Summary

Fixes onSelectionChange, onContentSizeChange, onScroll, and onKeyPress on Android Fabric — they were silently no-op for <PasteTextInput>.

Root cause

ReactTextInputManager gates these four listeners behind boolean @ReactProps (e.g. setOnSelectionChange(view, true) attaches the watcher). RN's built-in <TextInput> works because it ships a hand-written ViewConfig that lists these handlers as validAttributes, so React serializes them as boolean props when JS handlers are present.

Codegen-based components like <PasteTextInput> don't get that — the handlers are only registered as direct/bubbling events, never as attributes — so the Java setters never fire and the watchers stay unattached.

Fix

In PasteTextInputManager.addEventEmitters, attach all four watchers unconditionally. This matches built-in <TextInput>'s actual behaviour: it always passes its internal _onSelectionChange to the native side regardless of whether the user provided a handler, so the watchers are effectively always-on there too.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 9, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: efee349a-8f33-40f5-8275-d7326c7beb21

📥 Commits

Reviewing files that changed from the base of the PR and between e4658d4 and 7365311.

📒 Files selected for processing (1)
  • android/src/main/java/com/mattermost/pasteinputtext/PasteTextInputManager.kt

📝 Walkthrough

Walkthrough

PasteTextInputManager.addEventEmitters now unconditionally calls four TextInput event listener setters—onSelectionChange, onContentSizeChange, onScroll, onKeyPress—to ensure Fabric/codegen-based components receive these events regardless of @ReactProp presence.

Changes

Fabric Event Listener Support

Layer / File(s) Summary
Event Listener Setup
android/src/main/java/com/mattermost/pasteinputtext/PasteTextInputManager.kt
addEventEmitters unconditionally attaches onSelectionChange, onContentSizeChange, onScroll, and onKeyPress handlers to ensure Fabric/codegen component compatibility.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(android): attach missing events' directly and accurately summarizes the main change: attaching missing event listeners on Android.
Description check ✅ Passed The description provides comprehensive context about the root cause and fix, clearly relating to the changeset of attaching missing event listeners in PasteTextInputManager.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch attachAttributes

Comment @coderabbitai help to get the list of available commands and usage tips.

@enahum enahum merged commit 6051714 into master May 9, 2026
1 check passed
@enahum enahum deleted the attachAttributes branch May 9, 2026 03:25
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.

1 participant