react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

Custom fontSize in bottomTab will cut off and ellipsized on iOS after resume

Open kabus202 opened this issue 4 years ago • 11 comments

🐛 Bug Report

Custom fontSize in bottomTab cut off title text and ellipsized on iOS after resume

(A clear and concise description of what the bug is)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

To Reproduce

Navigation.setDefaultOptions({ bottomTab: { fontSize: 14, }, });

background -> resume app -> { ellipsis dots } -> click on each tab -> background -> resume -> all visible

Expected behavior

No dots

Actual Behavior

Ellipsis text in bottomBar

Your Environment

  • React Native Navigation version: latest
  • React Native version: 63.3
  • Platform(s) (iOS, Android, or both?): 7.4.1
  • Device info (Simulator/Device? OS version? Debug/Release?): tested with iOS14 / debug

kabus202 avatar Jan 22 '21 07:01 kabus202

same issues 7.15.0

dppo avatar Jun 03 '21 07:06 dppo

Also happens on iOS 14.3 Simulator on iPhone 12 with RNN v7.15.0. When activating a tab the label is fixed. Couldn't reproduce this on an actual device yet.

appleseedexm avatar Jun 10 '21 07:06 appleseedexm

The same issue 7.14.0 when icon is set.

ruscoder avatar Jun 10 '21 11:06 ruscoder

Still reproducing with react-native 0.66.2 and rnn 7.23.1

13thdeus avatar Nov 09 '21 08:11 13thdeus

Still occurs. I created minimal reproduction repo here: https://github.com/wix/react-native-navigation/issues/7072#issuecomment-964246173

stachu2k avatar Nov 10 '21 13:11 stachu2k

Workaround is to update tab title when app goes to "active" app state.

I've wrote a wrapper to use it on component registration:

export function BottomTabNameCorrector<P extends NavigationComponentProps>(
  tabId: string,
  Component: NavigationFunctionComponent<P>,
): NavigationFunctionComponent<P> {
  function Wrapper(props: P) {
    const onForeground = useCallback(() => {
      /*bottomTabsLayout is LayoutBottomTabs constant used to describe tabs root*/
      const tabTitle = bottomTabsLayout.children?.find(tabOptions => tabOptions.stack?.id == tabId)?.stack?.options?.bottomTab?.text;

      tabTitle && Navigation.mergeOptions(tabId, {
        bottomTab: {
          text: tabTitle,
        },
      });
    }, []);

    useAppState({onForeground}); // useAppState is simple hook which uses react-native AppState listener

    return (
      <Component {...props} />
    );
  }

  Wrapper.displayName = `BottomTabNameCorrector(${
    Component.displayName || Component.name
  })`;

  return isIos ? Wrapper : Component; // disabled for android
}

Usage: Navigation.registerComponent(Pages.menu.name, BottomTabNameCorrector(Tabs.menu.id, Menu));

13thdeus avatar Jan 19 '22 08:01 13thdeus

+1

any workarounds ?

Screenshot 2022-02-13 at 10 48 18 Screenshot 2022-02-13 at 10 47 54

arcziby avatar Feb 13 '22 10:02 arcziby

Happening for me as well on iPad (iPadOS 15.4)

  • react-native: 0.66.1
  • react-native-navigation: 7.25.1

haveneersrobin avatar Mar 30 '22 08:03 haveneersrobin

@13thdeus Hi. I'm trying to implement your workaround, but I can't figure out how did you get bottomTabsLayout. How can I import it?

stachu2k avatar Mar 31 '22 09:03 stachu2k

@13thdeus Hi. I'm trying to implement your workaround, but I can't figure out how did you get bottomTabsLayout. How can I import it?

It is an objct you've passed to Navigation.setRoot(bottomTabsLayout)

UPD: sorry in my case it is lools like this:

export const getTabsRootLayout = () => {
  return {
    root: {
      bottomTabs: bottomTabsLayout,
    },
  };
};
...
Navigation.setRoot(getTabsRootLayout());

13thdeus avatar Mar 31 '22 13:03 13thdeus

Let's solve it together here: https://github.com/wix/react-native-navigation/issues/7506#issuecomment-1160668701

olegderecha avatar Jun 20 '22 16:06 olegderecha

just remove the font-weight and add a font family with a bold text the issue will be resolved plus if you had different number of tabs according to your selection 1st what you have to do is check if your tabs length is greater then 1 then used the focus query other wise you just need to add the font family
fontFamily: categoryList.length > 1? focused ?bold:font_description:bold,

myexploitss avatar Jan 17 '23 13:01 myexploitss