Closed huytd1na closed 1 year ago
Thanks for reporting this issue, there have been multiple reports of this: most of them are closed without solution. For example: https://github.com/wix/react-native-navigation/issues/6533
There is one still open however, so yours is a duplicate of: https://github.com/wix/react-native-navigation/issues/6923
Ok, guys, let's resolve it together.
Based on this commit https://github.com/wix/react-native-navigation/commit/bafe9979abfeb6c651808c17eb13b36715abb8da I found, that the issue is in lib/ios/TabBarItemAppearanceCreator.m
file. If comment on these 2 lines:
- (void)setTitleAttributes:(UITabBarItem *)tabItem titleAttributes:(NSDictionary *)titleAttributes {
// tabItem.standardAppearance.stackedLayoutAppearance.normal.titleTextAttributes = titleAttributes;
tabItem.standardAppearance.compactInlineLayoutAppearance.normal.titleTextAttributes =
titleAttributes;
tabItem.standardAppearance.inlineLayoutAppearance.normal.titleTextAttributes = titleAttributes;
}
- (void)setSelectedTitleAttributes:(UITabBarItem *)tabItem
selectedTitleAttributes:(NSDictionary *)selectedTitleAttributes {
// tabItem.standardAppearance.stackedLayoutAppearance.selected.titleTextAttributes = selectedTitleAttributes;
tabItem.standardAppearance.compactInlineLayoutAppearance.selected.titleTextAttributes =
selectedTitleAttributes;
tabItem.standardAppearance.inlineLayoutAppearance.selected.titleTextAttributes =
selectedTitleAttributes;
}
the issue disappeared for me on iOS 15.4: THEN:
NOW:
So, if it works for you and you need to solve it right now, you can create a patch and apply it to your project as a temporary solution. I'm not a super iOS developer to create a PR, because I actually don't know what is happening here and why this line break it, but the definite place is determined and if somebody can help with a general solution - please share your thoughts.
@olegderecha thank for your solution.
this elipses issue has caused my most recent App Submission (July 19, 2022) to be rejected by Apple due to their "4.0.0 Design: Preamble"
hoping your solution gets my new build through the Review process.
@olegderecha Thank you for this post. This issue has been hitting me on iPad for over a year and your workaround seems to have finally made it go away.
So, in testing the fix today, I noticed the side effect of removing this line. Basically the default theming (in my case color, which I had overriden) returns when the tabs are selected. So we will likely need some middle-ground between the two.
I can't seem to see which option is tripping this though, AFAICT even if I remove all bottomTab/bottomTabs options, it still ends up with ellipsis without the removal suggested here.
Edit: it appears to work fine on iPad actually, but the color style on iPhones no longer matches my desired behavior.
This stack overflow thread suggests it is an IOS API bug (introduced in IOS 13 and apparently never fixed). https://stackoverflow.com/questions/69318520/ipados-15-uitabbar-title-cut-off
The suggestion was that adding the NSParagraphStyle.default
style to the normal attribute would fix the issue.
Edit: Tried this, my Objective-C is not the best but I didn't seem to be able to fix it using this technique. But I am fairly convinced at this point that we're looking at an IOS bug, and not a 'react-native-navigation' bug -- i.e. if you use the feature as it is documented, it will not work. Also like many iOS bugs, it seems like Apple has no interest in fixing it.
@zzorba , do you have a code solution for this? If your solution handles the real issue (not like mine, seems), we can create a PR to RNN then.
No, unfortunately my attempts at fixing it did not work. I've settled on using your solution for now -- would rather have a highlighted blue tab than have it cutoff.
So, I tried something else. I'n not sure if it is a universal fix but it seems to exhibit the correct behavior on both phones and tablets now. Basically the idea is detect if its an iPad and don't apply the problematic titleTextAttributes to the iPad controller which apple has left broken for the last 3 iOS releases.
--- a/node_modules/react-native-navigation/lib/ios/TabBarItemAppearanceCreator.m
+++ b/node_modules/react-native-navigation/lib/ios/TabBarItemAppearanceCreator.m
@@ -10,7 +10,9 @@ - (UITabBarItem *)createTabBarItem:(UITabBarItem *)mergeItem {
}
- (void)setTitleAttributes:(UITabBarItem *)tabItem titleAttributes:(NSDictionary *)titleAttributes {
- tabItem.standardAppearance.stackedLayoutAppearance.normal.titleTextAttributes = titleAttributes;
+ if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) {
+ tabItem.standardAppearance.stackedLayoutAppearance.normal.titleTextAttributes = titleAttributes;
+ }
tabItem.standardAppearance.compactInlineLayoutAppearance.normal.titleTextAttributes =
titleAttributes;
tabItem.standardAppearance.inlineLayoutAppearance.normal.titleTextAttributes = titleAttributes;
@@ -18,8 +20,9 @@ - (void)setTitleAttributes:(UITabBarItem *)tabItem titleAttributes:(NSDictionary
- (void)setSelectedTitleAttributes:(UITabBarItem *)tabItem
selectedTitleAttributes:(NSDictionary *)selectedTitleAttributes {
- tabItem.standardAppearance.stackedLayoutAppearance.selected.titleTextAttributes =
- selectedTitleAttributes;
+ if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) {
+ tabItem.standardAppearance.stackedLayoutAppearance.selected.titleTextAttributes = selectedTitleAttributes;
+ }
tabItem.standardAppearance.compactInlineLayoutAppearance.selected.titleTextAttributes =
selectedTitleAttributes;
tabItem.standardAppearance.inlineLayoutAppearance.selected.titleTextAttributes =
Having same issue. Can we change the position of text to be under the icon for iPad? I couldn't found the way for that either.
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,
I have a simple solution. It is weird but just works :) Why not just add some extra space after text like:
const extraSpace = ' ';
bottomTab: {
text: 'Screen Title' + extraSpace
}
Otherwise the issue still exists even after i have tried the solutions above.
I have a simple solution. It is weird but just works :) Why not just add some extra space after text like:
const extraSpace = ' '; bottomTab: { text: 'Screen Title' + extraSpace }
Otherwise the issue still exists even after i have tried the solutions above.
Yes. I even faced this solution but we can add 1 2 spaces otherwise the ui will be disturbed if its cutting 1 2 digits then we can add { } space like that
I have a simple solution. It is weird but just works :) Why not just add some extra space after text like:
const extraSpace = ' '; bottomTab: { text: 'Screen Title' + extraSpace }
Otherwise the issue still exists even after i have tried the solutions above.
Yes. I even faced this solution but we can add 1 2 spaces otherwise the ui will be disturbed if its cutting 1 2 digits then we can add { } space like that
I have added spaces if only it is an ipad. Have you tried that
Ok, guys, let's resolve it together. Based on this commit bafe997 I found, that the issue is in
lib/ios/TabBarItemAppearanceCreator.m
file. If comment on these 2 lines:- (void)setTitleAttributes:(UITabBarItem *)tabItem titleAttributes:(NSDictionary *)titleAttributes { // tabItem.standardAppearance.stackedLayoutAppearance.normal.titleTextAttributes = titleAttributes; tabItem.standardAppearance.compactInlineLayoutAppearance.normal.titleTextAttributes = titleAttributes; tabItem.standardAppearance.inlineLayoutAppearance.normal.titleTextAttributes = titleAttributes; } - (void)setSelectedTitleAttributes:(UITabBarItem *)tabItem selectedTitleAttributes:(NSDictionary *)selectedTitleAttributes { // tabItem.standardAppearance.stackedLayoutAppearance.selected.titleTextAttributes = selectedTitleAttributes; tabItem.standardAppearance.compactInlineLayoutAppearance.selected.titleTextAttributes = selectedTitleAttributes; tabItem.standardAppearance.inlineLayoutAppearance.selected.titleTextAttributes = selectedTitleAttributes; }
the issue disappeared for me on iOS 15.4: THEN: NOW:
So, if it works for you and you need to solve it right now, you can create a patch and apply it to your project as a temporary solution. I'm not a super iOS developer to create a PR, because I actually don't know what is happening here and why this line break it, but the definite place is determined and if somebody can help with a general solution - please share your thoughts.
This may work, but the problem is that it does not apply the style to the text, for example in our case the text of the selected tab bar is green and if I comment this it turns blue.
Any other way to patch the navigation to fix this?
Thanks!
Still facing this issue with the latest version 7.33.4
I'm facing the same problem on v7.34.0. The issue will be fixed by centered the text:
createFromDictionary:[tabItem titleTextAttributesForState:UIControlStateNormal]
fontFamily:fontFamily
fontSize:fontSize
fontWeight:fontWeight
color:textColor
centered:YES];
[self setTitleAttributes:tabItem titleAttributes:normalAttributes];
NSDictionary *selectedAttributes = [RNNFontAttributesCreator
createFromDictionary:[tabItem titleTextAttributesForState:UIControlStateSelected]
fontFamily:fontFamily
fontSize:fontSize
fontWeight:fontWeight
color:selectedTextColor
centered:YES];```
the same issue
Hi - I am having the same issue . Also How i can increase the padding? i am afraid this will be a showstopper.
🐛 Bug Report
Expected behavior
Actual Behavior
Your Environment
Are you willing to resolve this issue by submitting a Pull Request?