Skip to content

Commit

Permalink
Merge pull request #19339 from tienifr/fix/19310-buttons-add-attachme…
Browse files Browse the repository at this point in the history
…nt-not-responsive-ios

Fix: `Add attachments` and `Delete workspace` buttons are not responsive
  • Loading branch information
puneetlath authored May 20, 2023
2 parents 7378626 + 60bfb61 commit f4883cd
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/components/PopoverMenu/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'underscore';
import React from 'react';
import React, {useState} from 'react';
import PropTypes from 'prop-types';
import {View} from 'react-native';
import PopoverWithMeasuredContent from '../PopoverWithMeasuredContent';
Expand Down Expand Up @@ -40,11 +40,12 @@ const defaultProps = {

const PopoverMenu = (props) => {
const {isSmallScreenWidth} = useWindowDimensions();
const [selectedItemIndex, setSelectedItemIndex] = useState(null);

const selectItem = (index) => {
const selectedItem = props.menuItems[index];
props.onItemSelected(selectedItem);
selectedItem.onSelected();
setSelectedItemIndex(index);
};

const [focusedIndex, setFocusedIndex] = useArrowKeyFocusManager({initialFocusedIndex: -1, maxIndex: props.menuItems.length - 1});
Expand All @@ -66,7 +67,13 @@ const PopoverMenu = (props) => {
anchorAlignment={props.anchorOrigin}
onClose={props.onClose}
isVisible={props.isVisible}
onModalHide={() => setFocusedIndex(-1)}
onModalHide={() => {
setFocusedIndex(-1);
if (selectedItemIndex !== null) {
props.menuItems[selectedItemIndex].onSelected();
setSelectedItemIndex(null);
}
}}
animationIn={props.animationIn}
animationOut={props.animationOut}
animationInTiming={props.animationInTiming}
Expand Down

0 comments on commit f4883cd

Please sign in to comment.