Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cold-rabbits-grin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'react-native-bottom-tabs': patch
---

fix: make pressable items work when switching screens on new arch
3 changes: 3 additions & 0 deletions apps/example/src/Screens/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
Text,
TextInput,
View,
Button,
Alert,
} from 'react-native';

const MESSAGES = [
Expand All @@ -27,6 +29,7 @@ export function Chat({
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
style={styles.container}
>
<Button onPress={() => Alert.alert('Hey')} title="Press me" />
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={styles.inverted}
Expand Down
9 changes: 7 additions & 2 deletions apps/example/src/Screens/Contacts.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { useScrollToTop } from '@react-navigation/native';
import * as React from 'react';
import {
Alert,
FlatList,
type FlatListProps,
Platform,
SafeAreaView,
StyleSheet,
Text,
TouchableOpacity,
View,
} from 'react-native';
import { useBottomTabBarHeight } from 'react-native-bottom-tabs';
Expand Down Expand Up @@ -74,7 +76,10 @@ const CONTACTS: Item[] = [
const ContactItem = React.memo(
({ item }: { item: { name: string; number: number } }) => {
return (
<View style={[styles.item, { backgroundColor: '#fff' }]}>
<TouchableOpacity
style={[styles.item, { backgroundColor: '#fff' }]}
onPress={() => Alert.alert(`Pressed: ${item.name}`)}
>
<View style={styles.avatar}>
<Text style={styles.letter}>
{item.name.slice(0, 1).toUpperCase()}
Expand All @@ -84,7 +89,7 @@ const ContactItem = React.memo(
<Text style={styles.name}>{item.name}</Text>
<Text style={[styles.number, { opacity: 0.5 }]}>{item.number}</Text>
</View>
</View>
</TouchableOpacity>
);
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.LinearLayout
import android.widget.TextView
import androidx.core.view.children
import androidx.core.view.forEachIndexed
import coil3.ImageLoader
import coil3.asDrawable
Expand Down Expand Up @@ -138,7 +137,6 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
}

val container = createContainer()
child.isEnabled = false
container.addView(child, params)
layoutHolder.addView(container, index)

Expand All @@ -155,7 +153,8 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
FrameLayout.LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.MATCH_PARENT
)
visibility = INVISIBLE
isSaveEnabled = false
visibility = GONE
isEnabled = false
}
return container
Expand Down Expand Up @@ -183,12 +182,8 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
private fun toggleViewVisibility(view: View, isVisible: Boolean) {
check(view is ViewGroup) { "Native component tree is corrupted." }

view.visibility = if (isVisible) VISIBLE else INVISIBLE
view.visibility = if (isVisible) VISIBLE else GONE
view.isEnabled = isVisible

// Container has only 1 child, wrapped React Native view.
val reactNativeView = view.children.first()
reactNativeView.isEnabled = isVisible
}

private fun onTabSelected(item: MenuItem) {
Expand Down
6 changes: 1 addition & 5 deletions packages/react-native-bottom-tabs/src/TabView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@

if (!loaded.includes(focusedKey)) {
// Set the current tab to be loaded if it was not loaded before
setLoaded((loaded) => [...loaded, focusedKey]);

Check warning on line 210 in packages/react-native-bottom-tabs/src/TabView.tsx

View workflow job for this annotation

GitHub Actions / lint

'loaded' is already declared in the upper scope on line 206 column 10
}

const icons = React.useMemo(
Expand Down Expand Up @@ -324,11 +324,7 @@
importantForAccessibility={
focused ? 'auto' : 'no-hide-descendants'
}
style={
Platform.OS === 'android'
? [measuredDimensions]
: [{ position: 'absolute' }, measuredDimensions]
}
style={[{ position: 'absolute' }, measuredDimensions]}

Check warning on line 327 in packages/react-native-bottom-tabs/src/TabView.tsx

View workflow job for this annotation

GitHub Actions / lint

Inline style: { position: 'absolute' }
>
{renderScene({
route,
Expand Down
Loading