Skip to content

Commit

Permalink
Merge pull request #45178 from cretadn22/update-state
Browse files Browse the repository at this point in the history
Using setState to update state
  • Loading branch information
techievivek authored Jul 17, 2024
2 parents 3710936 + b4a4023 commit 5ca9922
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/PopoverMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,19 @@ function PopoverMenu({
onPress={() => {
setCurrentMenuItems(previousMenuItems);
setFocusedIndex(-1);
setEnteredSubMenuIndexes(enteredSubMenuIndexes.slice(0, -1));
setEnteredSubMenuIndexes((prevState) => prevState.slice(0, -1));
}}
/>
);
};

const renderHeaderText = () => {
if (!headerText || enteredSubMenuIndexes.length !== 0) {
return;
}
return <Text style={[styles.createMenuHeaderText, styles.ph5, styles.pv3]}>{headerText}</Text>;
};

useKeyboardShortcut(
CONST.KEYBOARD_SHORTCUTS.ENTER,
() => {
Expand Down Expand Up @@ -215,7 +222,7 @@ function PopoverMenu({
>
<FocusTrapForModal active={isVisible}>
<View style={isSmallScreenWidth ? {} : styles.createMenuContainer}>
{!!headerText && enteredSubMenuIndexes.length === 0 && <Text style={[styles.createMenuHeaderText, styles.ph5, styles.pv3]}>{headerText}</Text>}
{renderHeaderText()}
{enteredSubMenuIndexes.length > 0 && renderBackButtonItem()}
{currentMenuItems.map((item, menuIndex) => (
<FocusableMenuItem
Expand Down

0 comments on commit 5ca9922

Please sign in to comment.