Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix scroll on focus editor

ammarahm-edd4705d4f042a
diff --git a/apps/mobile/src/views/Editor/index.js b/apps/mobile/src/views/Editor/index.js
index 082188c98..ec957ef5f 100755
--- a/apps/mobile/src/views/Editor/index.js
+++ b/apps/mobile/src/views/Editor/index.js
@@ -1,5 +1,8 @@
import React, {useEffect, useState} from 'react';
+import {View} from 'react-native';
+import {Dimensions} from 'react-native';
import {Platform, ScrollView, TextInput} from 'react-native';
+import {useSafeAreaInsets} from 'react-native-safe-area-context';
import WebView from 'react-native-webview';
import {notesnook} from '../../../e2e/test.ids';
import {useTracked} from '../../provider';
@@ -44,12 +47,14 @@ const Editor = React.memo(
const [state] = useTracked();
const {premiumUser} = state;
const [resetting, setResetting] = useState(false);
+ const insets = useSafeAreaInsets();
+ const calculatedHeight =
+ Dimensions.get('window').height - (insets.top + insets.bottom + 50);
const onLoad = async () => {
await onWebViewLoad(premiumUser, getCurrentColors());
};
- const onResetRequested = async (noload) => {
-
+ const onResetRequested = async noload => {
setResetting(true);
await sleep(30);
setResetting(false);
@@ -74,30 +79,18 @@ const Editor = React.memo(
style={{height: 1, padding: 0, width: 1, position: 'absolute'}}
blurOnSubmit={false}
/>
- <ScrollView
- bounces={false}
- bouncesZoom={false}
- disableScrollViewPanResponder
- keyboardDismissMode="none"
- keyboardShouldPersistTaps="always"
- showsVerticalScrollIndicator={false}
- scrollEnabled={false}
+ <View
style={{
- height: '100%',
- width: '100%',
+ height: calculatedHeight,
}}
- nestedScrollEnabled
- contentContainerStyle={{
- width: '100%',
- height: '100%',
- }}>
+ nestedScrollEnabled>
<EditorHeader />
<WebView
testID={notesnook.ids.default.editor}
ref={EditorWebView}
onLoad={onLoad}
scrollEnabled={true}
- onRenderProcessGone={(event) => {
+ onRenderProcessGone={event => {
onResetRequested();
}}
javaScriptEnabled={true}
@@ -120,7 +113,7 @@ const Editor = React.memo(
autoManageStatusBarEnabled={false}
onMessage={_onMessage}
/>
- </ScrollView>
+ </View>
<EditorToolbar />
</>
);
diff --git a/apps/mobile/src/views/Editor/tiny/tiny.js b/apps/mobile/src/views/Editor/tiny/tiny.js
index 261efaa05..c700225e5 100644
--- a/apps/mobile/src/views/Editor/tiny/tiny.js
+++ b/apps/mobile/src/views/Editor/tiny/tiny.js
@@ -11,12 +11,16 @@ document.activeElement.blur();
window.blur();
`;
-const keyboardStateChanged = `(() => {
- window.scrollBy({
+/**
+ * window.scrollBy({
top: 45,
left: 0,
behavior: 'smooth'
})
+ */
+
+const keyboardStateChanged = `(() => {
+
})();
`;
const blur = `
diff --git a/apps/mobile/src/views/Editor/tiny/toolbar/index.js b/apps/mobile/src/views/Editor/tiny/toolbar/index.js
index 9f54f1c98..5fd382b4f 100644
--- a/apps/mobile/src/views/Editor/tiny/toolbar/index.js
+++ b/apps/mobile/src/views/Editor/tiny/toolbar/index.js
@@ -25,6 +25,7 @@ const EditorToolbar = React.memo(
<View
style={{
width: '100%',
+ minHeight: normalize(50),
}}>
<Tooltip />
<ScrollView