Skip to content

Conversation

@BogiKay
Copy link
Contributor

@BogiKay BogiKay commented Mar 3, 2025

Motivation

PR simplify and fix updateVisibility function in Menu component.

Related issue

#4631

Test plan

I tested changes using slightly changed example from the issue, which I'm attaching below and it's working fine

const ReproExample: React.FC<{ navigation: any }> = ({ navigation }) => {
  const [menuVisible, setMenuVisible] = useState(false);
  const [textValue, setTextValue] = useState('');
  const data = ['first', 'second', 'third'];

  useEffect(() => {
    console.log(menuVisible);
  }, [menuVisible]);

  return (
    <View>
      <Menu
        visible={menuVisible}
        onDismiss={() => setMenuVisible(false)}
        anchorPosition="bottom"
        children={getMenuItems(data)}
        anchor={
          <TextInput
            value={textValue}
            onChangeText={(newText: string) => {
              setTextValue(newText);
              if (menuVisible === true && newText === '') {
                setMenuVisible(false);
              } else if (menuVisible === false) {
                setMenuVisible(true);
              }
            }}
            onSubmitEditing={() => setMenuVisible(false)}
            autoComplete="address-line1"
            mode="outlined"
          ></TextInput>
        }
      ></Menu>
    </View>
  );
};

function getMenuItems(data: string[]): React.JSX.Element {
  return (
    <>
      {data.map((thing) => (
        <Menu.Item key={thing} title={thing}></Menu.Item>
      ))}
    </>
  );
}

@BogiKay BogiKay self-assigned this Mar 3, 2025
@BogiKay BogiKay added the Menu label Mar 3, 2025
@callstack-bot
Copy link

callstack-bot commented Mar 3, 2025

Hey @BogiKay, thank you for your pull request 🤗. The documentation from this branch can be viewed here.

@gpurbia
Copy link

gpurbia commented Mar 12, 2025

When do you plan to merge this and release it?

Copy link

@mamtajuddinIncapsulate mamtajuddinIncapsulate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good lets merge

@BogiKay BogiKay force-pushed the fix/menu-visibility branch from a571707 to 392d675 Compare April 2, 2025 16:08
@BogiKay
Copy link
Contributor Author

BogiKay commented Apr 2, 2025

Sorry for the delay. I was out on vacation recently and just getting back to things. Merging it now :)

@BogiKay BogiKay merged commit 00b00d2 into callstack:main Apr 2, 2025
3 checks passed
@dppo
Copy link

dppo commented Apr 9, 2025

Can a release package be published?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants