victorsoares96 / epubjs-react-native

ePub.js Reader for React Native
MIT License
143 stars 48 forks source link

Menu is buggy / out of sync #316

Open dcallus opened 1 day ago

dcallus commented 1 day ago

Summary

When selecting text very fast (i.e. letting go of selection straight away) on iPhone, the menu doesn't pop up and you must tap the selection to get the menu up.

Also, when you have logic in the menu e.g.

menuItems={
someFunction() ?
[
{
label: "Dictionary",
key: "dictionary",
},
{
label: "Copy",
key: "copy",
}
]
:
[]
}

the menu can get out of sync. It may display when it's not supposed to and not display when it should. Almost like it's using a ref that's behind state, but not always, just on occasion.

What platform(s) does this occur on?

iOS

What workflow(s) does this occur on?

Expo Workflow

Environment (or package.json)

{ "name": "pagepal", "version": "1.0.0", "main": "node_modules/expo/AppEntry.js", "scripts": { "start": "expo start", "android": "expo start --android", "ios": "expo start --ios", "web": "expo start --web", "lint": "eslint ." }, "dependencies": { "@dr.pogodin/react-native-static-server": "^0.12.0", "@epubjs-react-native/core": "^1.4.1", "@epubjs-react-native/expo-file-system": "^1.1.3", "@gorhom/bottom-sheet": "^4.6.1", "@react-native-async-storage/async-storage": "1.23.1", "@react-navigation/bottom-tabs": "^6.6.1", "@react-navigation/elements": "^1.3.30", "@react-navigation/native": "^6.1.17", "@react-navigation/stack": "^6.3.29", "@tanstack/react-query": "^5.52.1", "axios": "^1.6.8", "buffer": "^6.0.3", "epubjs": "^0.3.93", "expo": "^51.0.32", "expo-av": "~14.0.5", "expo-document-picker": "~12.0.1", "expo-file-system": "~17.0.1", "expo-linear-gradient": "~13.0.2", "expo-status-bar": "~1.12.1", "lucide-react-native": "^0.426.0", "moti": "^0.28.1", "react": "18.2.0", "react-native": "0.74.1", "react-native-drawer-layout": "^3.3.0", "react-native-fs": "^2.20.0", "react-native-gesture-handler": "~2.16.1", "react-native-modal": "^13.0.1", "react-native-paper": "^5.12.5", "react-native-reanimated": "~3.10.1", "react-native-safe-area-context": "4.10.1", "react-native-screens": "3.31.1", "react-native-svg": "^15.5.0", "react-native-webview": "13.8.6" }, "devDependencies": { "@babel/core": "^7.20.0", "@expo/metro-runtime": "~3.2.3", "eslint": "8.0.0", "eslint-config-universe": "^12.0.0", "react-dom": "18.2.0", "react-native-web": "~0.19.10" }, "private": true }

Your .epub file

No response

Minimal reproducible example

No response

I confirm that i have

dcallus commented 1 day ago

Okay I've done some experimenting. Moving the function calculation outside of the menuItems and calculating it beforehand does NOT help. The two bugs I listed are in fact related.

The only time we get the wrong (previous) menu pop up, is if a quick release is done. Very similar to how we get no menu popup at all when releasing quickly.