jasongaare / react-native-walkthrough-tooltip

An inline wrapper for calling out React Native components via tooltip
MIT License
610 stars 182 forks source link

Content cut off in tooltip #152

Open dansimau opened 2 years ago

dansimau commented 2 years ago

I am trying to build a simple tooltip:

const styles = StyleSheet.create({
  tooltipTitle: {
    marginBottom: 10,
    fontWeight: "bold",
  },
  tooltipText: {
    color: "#444",
    fontSize: 16,
    lineHeight: 20,
  },
});

export const makeTooltipContent = (opts: {title?: string; text: string}) => (
  <View style={{padding: 8}}>
    {opts.title !== undefined ? (
      <Text style={[styles.tooltipText, styles.tooltipTitle]}>
        {opts.title}
      </Text>
    ) : null}

    <Text style={styles.tooltipText}>{opts.text}</Text>
  </View>
);

Snippet from my component:

                <Tooltip
                  isVisible={true}
                  content={makeTooltipContent({
                    title: "Leave a personal note",
                    text: "Help others know why a place is great. ✨",
                  })}
                  placement="left">
                  <FilledButton style={Buttons.Text} title="Add tip" />
                </Tooltip>

The result is:

Screenshot 2022-04-25 at 17 01 09

Am I missing something?

apfritts commented 2 years ago

@dansimau did you find a solution to this? Or figure out what was causing it? We're QA'ing our app now and it's happening to our production builds but wasn't happening in dev builds :sob:

apfritts commented 2 years ago

I ended up fixing this by adding {flex: 1, flexGrow: 1} to the text style.

topherPedersen commented 2 years ago

I ran into this issue today as well. I think the issue might have something to do with Text components? I tried removing the text component, and replaced it with a red square and things started working again.

Also, when you make CSS changes to the tooltip, you may need to reload the app by pressing 'r' in the metro bundler console. I noticed when I just hit save and the app does a hot reload, sometimes the tooltips won't render correctly. But if I press 'r' in the metro bundler terminal, and then log back into my organization's app, then things would start rendering properly.