Skip to content

Commit 6215b44

Browse files
refactor: inline row press logic into onPress, drop useOptionRowLHNCorePress
1 parent 333f236 commit 6215b44

1 file changed

Lines changed: 9 additions & 26 deletions

File tree

src/components/LHNOptionsList/OptionRowLHN/OptionRowPressable.tsx

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,6 @@ import {showContextMenu} from '@pages/inbox/report/ContextMenu/ReportActionConte
1515
import variables from '@styles/variables';
1616
import CONST from '@src/CONST';
1717

18-
type OptionRowLHNCorePressHandler = (event: GestureResponderEvent | KeyboardEvent | undefined) => void;
19-
20-
type UseOptionRowLHNCorePressParams = {
21-
reportID: string;
22-
optionItem: OptionData;
23-
popoverAnchor: RefObject<View | null>;
24-
onSelectRow: (optionItem: OptionData, popoverAnchor: RefObject<View | null>) => void;
25-
};
26-
27-
/** LHN row press: telemetry span, composer focus, then onSelectRow. Lives next to OptionRowPressable per review. */
28-
function useOptionRowLHNCorePress({reportID, optionItem, popoverAnchor, onSelectRow}: UseOptionRowLHNCorePressParams): OptionRowLHNCorePressHandler {
29-
return (event: GestureResponderEvent | KeyboardEvent | undefined) => {
30-
startSpan(`${CONST.TELEMETRY.SPAN_OPEN_REPORT}_${reportID}`, {
31-
name: 'OptionRowLHN',
32-
op: CONST.TELEMETRY.SPAN_OPEN_REPORT,
33-
});
34-
35-
event?.preventDefault();
36-
// Enable Composer to focus on clicking the same chat after opening the context menu.
37-
ReportActionComposeFocusManager.focus();
38-
onSelectRow(optionItem, popoverAnchor);
39-
};
40-
}
41-
4218
type OptionRowPressableProps = {
4319
reportID: string;
4420
optionItem: OptionData;
@@ -69,10 +45,17 @@ function OptionRowPressable({
6945
testID,
7046
children,
7147
}: OptionRowPressableProps) {
72-
const corePress = useOptionRowLHNCorePress({reportID, optionItem, popoverAnchor, onSelectRow});
7348
const onPress = (event: GestureResponderEvent | KeyboardEvent | undefined) => {
7449
onPressBefore?.();
75-
corePress(event);
50+
startSpan(`${CONST.TELEMETRY.SPAN_OPEN_REPORT}_${reportID}`, {
51+
name: 'OptionRowLHN',
52+
op: CONST.TELEMETRY.SPAN_OPEN_REPORT,
53+
});
54+
55+
event?.preventDefault();
56+
// Enable Composer to focus on clicking the same chat after opening the context menu.
57+
ReportActionComposeFocusManager.focus();
58+
onSelectRow(optionItem, popoverAnchor);
7659
};
7760
const theme = useTheme();
7861
const styles = useThemeStyles();

0 commit comments

Comments
 (0)