Android Hardware Back Button causes Blank Screen
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- android, javascript, react-native
- Lĩnh vực
- mobile-dev
Hướng nghiên cứu
Bắt đầu với thiết lập điều hướng trong index.js và các tùy chọn Android hardwareBackButton, sau đó thực hiện các bước tái hiện được liệt kê trên các phiên bản React Native và Android đã nêu. So sánh hành vi khi khởi chạy lại với workaround Native Back Handler; hoàn tất khi khởi chạy lại sau hardware Back Button không hiển thị màn hình trống.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
🐛 Bug Report
Only on Android, when the user uses the Hardware Back Button and they are at the landing screen, the Activity closes. Then when the application is started again I see a blank screen. This happens only if I use the hardware back. If I minimize the application using the hardware home button, then there are no issues.
I read somewhere that I should use the events().registerAppLaunchedListener but that doesn't get invoked.
Have you read the Contributing Guidelines on issues?
Yes, I have read them.
To Reproduce
- Create a blank application using the React Native CLI
- Install the latest version of the navigation library
- Create a Bottom Navigation
- As the first tab create a Stack Navigator
- Press the hardware back button on the phone
- Enter the application again
ERROR: Blank screen.
NOTES: I am using a legacy project that somebody else wrote and I am trying to maintain/update it.
The way the bottom tab bar is created is very weird to me. I found that this code causes the tab bar to appear, however, without this code the tab bar is missing:
// hide the tab bar when navigating to screens that are not in tabBarScreens
Navigation.events().registerCommandListener((name, params) => {
let componentNames = params &&
params.layout &&
params.layout.data && [params.layout.data.name]
componentNames =
componentNames ||
(params &&
params.layout &&
Array.isArray(params.layout) &&
params.layout
.map((layout) => layout.data && layout.data.name)
.filter((c) => c !== undefined))
if (componentNames && componentNames.length === 0) {
componentNames = undefined
}
componentNames =
componentNames ||
(params &&
params.layout &&
params.layout.children &&
params.layout.children
.map((child) => child.data && child.data.name)
.filter((c) => c !== undefined))
if (componentNames && componentNames.length === 0) {
componentNames = undefined
}
componentNames =
componentNames ||
(params &&
params.layout &&
params.layout.root &&
params.layout.root.children &&
params.layout.root.children
.map((child) => child.data && child.data.name)
.filter((c) => c !== undefined))
console.log({ name, params })
switch (name) {
case 'push':
case 'showModal':
if (componentNames && componentNames.length > 0) {
if (
getTabBarScreen(componentNames[componentNames.length - 1]) ===
undefined
) {
store.dispatch(setShouldBeVisible(false))
screenStack.push({
componentName: componentNames[componentNames.length - 1],
tabBarVisible: false,
})
} else {
screenStack.push({
componentName: componentNames[componentNames.length - 1],
})
}
}
break
case 'pop':
case 'dismissModal':
if (screenStack.length > 1) {
screenStack.pop()
}
break
case 'popToRoot':
screenStack = [screenStack[0]]
break
case 'setRoot':
case 'setStackRoot':
if (componentNames && componentNames.length > 0) {
screenStack = componentNames.map((c) => {
return { componentName: c }
})
}
break
}
})
The stack navigation is created as follows:
// This code is executed in the index.js file
let navStack = [
{
screenName: MainScreen.screenName(),
passProps: {
initial: true,
navigateToRunning: true,
},
},
]
const createNavigationStack = (screenList) => {
return screenList.map((item) => {
return {
component: {
name: item.screenName,
passProps: item.passProps,
options: {
animations: {
setStackRoot: {
enabled: false,
},
},
popGesture: false,
hardwareBackButton: {
dismissModalOnPress: true,
popStackOnPress: true,
bottomTabsOnPress: 'previous',
},
},
},
}
})
}
Navigation.setRoot(createNavigationStack(navStack))
I have no idea why things are done this way. The only workaround to my problem was to override the Native Back Handler and just disable it:
BackHandler.addEventListener('hardwareBackPress', () => true);
Expected behavior
I expect that the application will return to the last screen that was displayed when it is relaunched.
Actual Behavior
A Blank screen is shown
Your Environment
- React Native Navigation version: 7.30.2
- React Native version: 0.70.5
- Platform(s) (iOS, Android, or both?): Android 11
- Device info (Simulator/Device? OS version? Debug/Release?): Simulator + Samsung Galaxy S20 FE, both Debug and Release
Reproducible Demo
N/A, the code is proprietry.
Are you willing to resolve this issue by submitting a Pull Request?
- ✖️ Yes, I have the time, and I know how to start.
- ✖️ Yes, I have the time, but I don't know how to start. I would need guidance.
- ✅ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
- Ngôn ngữ chính
- MDX
- Star
- 13.2k
- Fork
- 2.6k
- Merge trung bình
- 3 giờ 21 phút
- Pull request đã merge (30 ngày)
- 5
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của wix/react-native-navigation
-
needs triage triage: documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
wix/react-native-navigation#8343 · 1 bình luận ·
-
[Fix] searchBar `focus:` true ignored on mergeOptions when searchController already existsCó thể đã có người làm @IsaacIsrael đã nhận 162 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
wix/react-native-navigation#8318 ·
-
Build Failed with RN 0.87Đang mởneeds triage type: accepted/bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
wix/react-native-navigation#8365 · 2 bình luận ·
-
`showOverlay` creates a scene-less `UIWindow`, so overlays never appear under UIScene lifecycleCó thể đã có người làm @yedidyak đã nhận 7 ngày trước. Đang mởplatform: iOS type: accepted/bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
wix/react-native-navigation#8345 · 2 bình luận · 2 reaction ·
-
platform: iOS type: accepted/bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
wix/react-native-navigation#8340 ·
Tất cả issue của wix/react-native-navigation
Issue tương tự
-
carp demo apps enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
carp-dk/carp.sensing-flutter#670 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
software-mansion/argent#1854 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Android: NativeAdView redraws every frame while idle (requestLayout → bringChildToFront loop)Có thể đã có người làm @cilladev đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
invertase/react-native-google-mobile-ads#930 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100