Page MenuHomePhabricator

[native] Emit artificial onSelectionChange alongside onChangeText in ClearableTextInput
ClosedPublic

Authored by ashoat on Feb 18 2023, 12:11 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 23, 7:43 AM
Unknown Object (File)
Sun, Dec 22, 4:19 PM
Unknown Object (File)
Sun, Dec 22, 4:18 PM
Unknown Object (File)
Sun, Dec 22, 4:18 PM
Unknown Object (File)
Sun, Dec 22, 4:18 PM
Unknown Object (File)
Nov 1 2024, 11:17 AM
Unknown Object (File)
Nov 1 2024, 11:16 AM
Unknown Object (File)
Nov 1 2024, 11:16 AM
Subscribers
None

Details

Summary

When clearing the input in ClearableTextInput, we construct an artificial onChangeText event. This confuses SelectableTextInput, which expects that onChangeText events should always be accompanied by onSelectionChange events.

As a result of this interaction, a bug occurs because ClearableTextInput defers emiting an onUpdateSyncedSelectionData event until it receives the corresponding onSelectionChange.

This diff addresses the issues by adding an artificial onSelectionChange event alongside the artificial onChangeText event. On iOS onSelectionChange comes first, but on Android it comes last.

Test Plan

Before this change, I had noticed a bug where the @-mention typeahead would not clear after text input cleared. After this change the issue was gone.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Harbormaster returned this revision to the author for changes because remote builds failed.Feb 18 2023, 12:27 PM
Harbormaster failed remote builds in B16594: Diff 22700!

Rebase on master to fix CI

Before this change, I had noticed a bug where the @-mention typeahead would not clear after text input cleared. After this change the issue was gone.

Based on Summary, assuming this was tested on both iOS and Android

native/components/clearable-text-input.react.ios.js
117–121 ↗(On Diff #22743)

Thanks for including this explanation

This revision is now accepted and ready to land.Feb 20 2023, 2:28 PM