Skip to content

Commit 0d00e13

Browse files
authored
fix: Add deprecated receiveCommand method (#601)
Support deprecated receiveCommand which receives commandId as int. It may be RN bug and also dependent on RN version, but running on RN 0.76.2 (old arch), the `receiveCommand` which accepts `String commandId` is never called, therefore calling `focus()` and `blur()` functions does nothing. Here we manually delegate this call using the deprecated `receiveCommand`. JS sends the command id as Int.
1 parent 6fbcf6e commit 0d00e13

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

android/src/main/java/com/reactnativecommunity/picker/ReactPickerManager.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,17 @@ protected void addEventEmitters(
217217
picker.setOnFocusListener(eventEmitter);
218218
}
219219

220+
@Override
221+
public void receiveCommand(@NonNull ReactPicker root, int commandId, @androidx.annotation.Nullable ReadableArray args) {
222+
Map<String, Integer> commands = getCommandsMap();
223+
if(commands == null) return;
224+
for (Map.Entry<String, Integer> entry : commands.entrySet()) {
225+
if (commandId == entry.getValue()) {
226+
receiveCommand(root, entry.getKey(), args);
227+
}
228+
}
229+
}
230+
220231
@Override
221232
public void receiveCommand(@NonNull ReactPicker root, String commandId, @androidx.annotation.Nullable ReadableArray args) {
222233
Assertions.assertNotNull(root);

0 commit comments

Comments
 (0)