From 7b4e7d117f4a2d1259a06593bfcf348bda7e5603 Mon Sep 17 00:00:00 2001 From: ammarahm-ed Date: Mon, 19 Jul 2021 12:39:30 +0500 Subject: [PATCH] fix editor focus --- apps/mobile/src/components/CustomTabs/index.js | 4 +++- apps/mobile/src/views/Editor/Functions.js | 3 +++ apps/mobile/src/views/Editor/tiny/tiny.js | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/mobile/src/components/CustomTabs/index.js b/apps/mobile/src/components/CustomTabs/index.js index a7eb305ef..6d28d3a6d 100644 --- a/apps/mobile/src/components/CustomTabs/index.js +++ b/apps/mobile/src/components/CustomTabs/index.js @@ -87,6 +87,7 @@ export default class CustomTabs extends Component { editing.keyboardState = false; this.inputElement.current?.focus(); this.inputElement.current?.blur(); + console.log('hiding keyboard from custom tabs'); } } @@ -124,7 +125,7 @@ export default class CustomTabs extends Component { this.moved = true; this.scrollOffset = event.nativeEvent.contentOffset.x; - if (this.scrollOffset < this.props.offsets.b - 100 || this.nextPage !== 1) { + if (this.scrollOffset < this.props.offsets.b - 100 && this.nextPage !== 1) { editing.movedAway = true; } else { editing.movedAway = false; @@ -173,6 +174,7 @@ export default class CustomTabs extends Component { editing.movedAway = false; } else { this.nextPage = 0; + console.log('moved away here',editing.movedAway); editing.movedAway = true; this.hideKeyboardIfVisible(); } diff --git a/apps/mobile/src/views/Editor/Functions.js b/apps/mobile/src/views/Editor/Functions.js index 0bfa941ba..0b2d08cab 100644 --- a/apps/mobile/src/views/Editor/Functions.js +++ b/apps/mobile/src/views/Editor/Functions.js @@ -184,7 +184,10 @@ let webviewTimer = null; export const loadNote = async item => { editing.currentlyEditing = true; + editing.movedAway = false; + if (editing.isFocused) { tiny.call(EditorWebView, tiny.blur); + } if (item && item.type === 'new') { if (getNote()) { await clearEditor(); diff --git a/apps/mobile/src/views/Editor/tiny/tiny.js b/apps/mobile/src/views/Editor/tiny/tiny.js index 85d3832fc..655a1f01b 100644 --- a/apps/mobile/src/views/Editor/tiny/tiny.js +++ b/apps/mobile/src/views/Editor/tiny/tiny.js @@ -83,6 +83,7 @@ const updateSavingState = value => ` `; export const clearEditor = ` + tinymce.activeEditor.setContent(""); `; const clearTitle = ` @@ -151,6 +152,7 @@ isLoading = false; const html = value => post('html', value); const focusEditor = ` +window.focus(); tinymce.activeEditor.focus(); `;