Expo 54: Scrolling is broken on iOS/Android and positioning is off on Android
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- react-native, typescript
- Lĩnh vực
- mobile
Hướng nghiên cứu
Bắt đầu bằng cách xác định mã nguồn của CopilotProvider tương ứng với dist/index.js và đọc src/components/CopilotStep.tsx, sau đó tái hiện hành vi cuộn và định vị trong một ứng dụng Expo 54 trên iOS và Android. So sánh diff được báo cáo với mã nguồn và xác minh rằng việc cuộn walkthrough và định vị các bước là chính xác trên cả hai nền tảng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi! 👋
Firstly, thanks for your work on this project! 🙂
As I have clarified in the title, there are scroll and positioning related issues when we use this package in a project built with Expo 54
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-copilot/dist/index.js b/node_modules/react-native-copilot/dist/index.js
index 3aff2e2..ad074f8 100644
--- a/node_modules/react-native-copilot/dist/index.js
+++ b/node_modules/react-native-copilot/dist/index.js
@@ -893,7 +893,7 @@ var CopilotProvider = (_a) => {
const copilotEvents = (0, import_react8.useRef)((0, import_mitt.default)()).current;
const modal = (0, import_react8.useRef)(null);
const [visible, setVisibility] = useStateWithAwait(false);
- const [scrollView, setScrollView] = (0, import_react8.useState)(null);
+ const scrollViewRef = (0, import_react8.useRef)(null);
const {
currentStep,
currentStepNumber,
@@ -927,20 +927,17 @@ var CopilotProvider = (_a) => {
);
const setCurrentStep = (0, import_react8.useCallback)(
(step, move = true) => __async(void 0, null, function* () {
- var _a2;
setCurrentStepState(step);
copilotEvents.emit("stepChange", step);
- if (scrollView != null) {
- const nodeHandle = (0, import_react_native7.findNodeHandle)(scrollView);
- if (nodeHandle) {
- (_a2 = step == null ? void 0 : step.wrapperRef.current) == null ? void 0 : _a2.measureLayout(
- nodeHandle,
- (_x, y, _w, h) => {
- const yOffset = y > 0 ? y - h / 2 : 0;
- scrollView.scrollTo({ y: yOffset, animated: false });
- }
- );
- }
+ if (scrollViewRef.current != null && step?.wrapperRef.current) {
+ step.wrapperRef.current.measure((_x, _y, _w, h, _pageX, pageY) => {
+ if (pageY !== undefined && h !== undefined) {
+ // Scroll so element appears in upper portion of screen
+ // leaving room for tooltip below
+ const yOffset = Math.max(0, pageY - 150);
+ scrollViewRef.current.scrollTo({ y: yOffset, animated: false });
+ }
+ });
}
setTimeout(
() => {
@@ -948,16 +945,17 @@ var CopilotProvider = (_a) => {
void moveModalToStep(step);
}
},
- scrollView != null ? 100 : 0
+ scrollViewRef.current != null ? 100 : 0
);
}),
- [copilotEvents, moveModalToStep, scrollView, setCurrentStepState]
+ [copilotEvents, moveModalToStep, setCurrentStepState]
);
const start = (0, import_react8.useCallback)(
(fromStep, suppliedScrollView = null) => __async(void 0, null, function* () {
- if (scrollView == null) {
- setScrollView(suppliedScrollView);
+ if (suppliedScrollView != null) {
+ scrollViewRef.current = suppliedScrollView;
}
+
const currentStep2 = fromStep ? steps[fromStep] : getFirstStep();
if (startTries.current > MAX_START_TRIES) {
startTries.current = 0;
@@ -980,7 +978,6 @@ var CopilotProvider = (_a) => {
copilotEvents,
getFirstStep,
moveModalToStep,
- scrollView,
setCurrentStep,
setVisibility,
steps
@@ -1071,6 +1068,7 @@ function walkthroughable(WrappedComponent) {
// src/components/CopilotStep.tsx
var import_react11 = __toESM(require("react"));
+var import_react_native9 = require("react-native");
var CopilotStep = ({
name,
order,
@@ -1086,9 +1084,15 @@ var CopilotStep = ({
const measure2 = () => {
if (wrapperRef.current != null && "measure" in wrapperRef.current) {
wrapperRef.current.measure((_ox, _oy, width, height, x, y) => {
+ // Adjust for Android status bar
+ let adjustedY = y;
+ if (import_react_native9.Platform.OS === 'android') {
+ const statusBarHeight = import_react_native9.StatusBar.currentHeight || 0;
+ adjustedY = y + statusBarHeight;
+ }
resolve({
x,
- y,
+ y: adjustedY,
width,
height
});
- Ngôn ngữ chính
- TypeScript
- Star
- 2.4k
- Fork
- 425
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
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 mohebifar/react-native-copilot
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
mohebifar/react-native-copilot#354 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
mohebifar/react-native-copilot#349 · 11 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 15/100
mohebifar/react-native-copilot#348 · 2 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
Tất cả issue của mohebifar/react-native-copilot
Issue tương tự
-
[Bug]: RUN_STARTED resets the run's tool-call tally even when a subscriber suppresses the eventĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
ag-ui-protocol/ag-ui#3504 ·
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 68/100
Dokploy/dokploy#6151 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/profiles area/sessions comp/desktop desktop/chat desktop/sessions P2 type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
NousResearch/hermes-agent#161712 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug p3
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
rothgar/rabble.radio#283 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug from-app needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
nightly-labs/openbot#19805 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày