Skip to content

Commit 63fa8d1

Browse files
committed
fix: make pressable items work when switching screens on new arch
1 parent 88e1bfb commit 63fa8d1

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

.changeset/cold-rabbits-grin.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'react-native-bottom-tabs': patch
3+
---
4+
5+
fix: make pressable items work when switching screens on new arch

packages/react-native-bottom-tabs/android/src/main/java/com/rcttabview/RCTTabView.kt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import android.view.ViewGroup
1818
import android.widget.FrameLayout
1919
import android.widget.LinearLayout
2020
import android.widget.TextView
21-
import androidx.core.view.children
2221
import androidx.core.view.forEachIndexed
2322
import coil3.ImageLoader
2423
import coil3.asDrawable
@@ -138,7 +137,6 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
138137
}
139138

140139
val container = createContainer()
141-
child.isEnabled = false
142140
container.addView(child, params)
143141
layoutHolder.addView(container, index)
144142

@@ -155,7 +153,8 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
155153
FrameLayout.LayoutParams.MATCH_PARENT,
156154
FrameLayout.LayoutParams.MATCH_PARENT
157155
)
158-
visibility = INVISIBLE
156+
isSaveEnabled = false
157+
visibility = GONE
159158
isEnabled = false
160159
}
161160
return container
@@ -183,12 +182,8 @@ class ReactBottomNavigationView(context: Context) : LinearLayout(context) {
183182
private fun toggleViewVisibility(view: View, isVisible: Boolean) {
184183
check(view is ViewGroup) { "Native component tree is corrupted." }
185184

186-
view.visibility = if (isVisible) VISIBLE else INVISIBLE
185+
view.visibility = if (isVisible) VISIBLE else GONE
187186
view.isEnabled = isVisible
188-
189-
// Container has only 1 child, wrapped React Native view.
190-
val reactNativeView = view.children.first()
191-
reactNativeView.isEnabled = isVisible
192187
}
193188

194189
private fun onTabSelected(item: MenuItem) {

packages/react-native-bottom-tabs/src/TabView.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,7 @@ const TabView = <Route extends BaseRoute>({
324324
importantForAccessibility={
325325
focused ? 'auto' : 'no-hide-descendants'
326326
}
327-
style={
328-
Platform.OS === 'android'
329-
? [measuredDimensions]
330-
: [{ position: 'absolute' }, measuredDimensions]
331-
}
327+
style={[{ position: 'absolute' }, measuredDimensions]}
332328
>
333329
{renderScene({
334330
route,

0 commit comments

Comments
 (0)