Files
react-native/packages/react-native-popup-menu-android/js/PopupMenuAndroidNativeComponent.android.js
T
Alan Lee 47c6311422 fix issue with PopupMenuAndroid event (#44103)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44103

Changes here fixes events in PopupMenuAndroid not being triggered correctly.

Issuses were:
1) naming mismatch
2) wrong parameters were set for the Event Map
3) missing code in .cpp

Applied fixes:
1) consistent event naming
2) fixed key used for event mapping
3) re-ran codegen to update .cpp files

## Changelog:

[Android] [internal] - Fix issue with PopupMenuAndroid event callback not working

Steps took to run codegen for this diff: https://www.internalfb.com/intern/phabricator/paste/markdown/P1214671854/

This diff is patching issues from D55531870

Reviewed By: RSNara

Differential Revision: D56164235

fbshipit-source-id: 4cf66ad3cfd753c146c5e219f27910834731e183
2024-04-16 00:27:57 -07:00

51 lines
1.4 KiB
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes';
import type {HostComponent} from 'react-native/Libraries/Renderer/shims/ReactNativeTypes';
import type {
DirectEventHandler,
Int32,
} from 'react-native/Libraries/Types/CodegenTypes';
import * as React from 'react';
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
type PopupMenuSelectionEvent = $ReadOnly<{
item: Int32,
}>;
type PopupMenuDismissEvent = $ReadOnly<{}>;
type NativeProps = $ReadOnly<{
...ViewProps,
//Props
menuItems?: ?$ReadOnlyArray<string>,
onPopupMenuSelectionChange?: DirectEventHandler<PopupMenuSelectionEvent>,
onPopupMenuDismiss?: DirectEventHandler<PopupMenuDismissEvent>,
}>;
type ComponentType = HostComponent<NativeProps>;
interface NativeCommands {
+show: (viewRef: React.ElementRef<ComponentType>) => void;
}
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
supportedCommands: ['show'],
});
export default (codegenNativeComponent<NativeProps>(
'AndroidPopupMenu',
): HostComponent<NativeProps>);