From ae7767de668b9597f9d17aad26146d5f12bbcae8 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Tue, 27 Jul 2021 16:58:54 +0300 Subject: [PATCH] [mobile] Fix bug 51532 --- apps/documenteditor/mobile/src/page/main.jsx | 61 +++++++++++------- .../mobile/src/page/main.jsx | 62 ++++++++++++------- .../mobile/src/page/main.jsx | 55 ++++++++++------ 3 files changed, 114 insertions(+), 64 deletions(-) diff --git a/apps/documenteditor/mobile/src/page/main.jsx b/apps/documenteditor/mobile/src/page/main.jsx index a502fca1a..371c3fa27 100644 --- a/apps/documenteditor/mobile/src/page/main.jsx +++ b/apps/documenteditor/mobile/src/page/main.jsx @@ -28,35 +28,49 @@ class MainPage extends Component { handleClickToOpenOptions = (opts, showOpts) => { ContextMenu.closeContextMenu(); - this.setState(state => { - if ( opts == 'edit' ) - return {editOptionsVisible: true}; - else if ( opts == 'add' ) - return { - addOptionsVisible: true, - addShowOptions: showOpts - }; - else if ( opts == 'settings' ) - return {settingsVisible: true}; - else if ( opts == 'coauth' ) - return { - collaborationVisible: true, - collaborationPage: showOpts - }; - }); + setTimeout(() => { + let opened = false; + const newState = {}; + if ( opts === 'edit' ) { + this.state.editOptionsVisible && (opened = true); + newState.editOptionsVisible = true; + } else if ( opts === 'add' ) { + this.state.addOptionsVisible && (opened = true); + newState.addOptionsVisible = true; + newState.addShowOptions = showOpts; + } else if ( opts === 'settings' ) { + this.state.settingsVisible && (opened = true); + newState.settingsVisible = true; + } else if ( opts === 'coauth' ) { + this.state.collaborationVisible && (opened = true); + newState.collaborationVisible = true; + } - if ((opts === 'edit' || opts === 'coauth') && Device.phone) { - f7.navbar.hide('.main-navbar'); - } + for (let key in this.state) { + if (this.state[key] && !opened) { + setTimeout(() => { + this.handleClickToOpenOptions(opts, showOpts); + }, 10); + return; + } + } + + if (!opened) { + this.setState(newState); + if ((opts === 'edit' || opts === 'coauth') && Device.phone) { + f7.navbar.hide('.main-navbar'); + } + } + }, 10); }; handleOptionsViewClosed = opts => { - (async () => { - await 1 && this.setState(state => { + setTimeout(() => { + this.setState(state => { if ( opts == 'edit' ) return {editOptionsVisible: false}; else if ( opts == 'add' ) - return {addOptionsVisible: false}; + return {addOptionsVisible: false, addShowOptions: null}; else if ( opts == 'settings' ) return {settingsVisible: false}; else if ( opts == 'coauth' ) @@ -65,7 +79,8 @@ class MainPage extends Component { if ((opts === 'edit' || opts === 'coauth') && Device.phone) { f7.navbar.show('.main-navbar'); } - })(); + }, 1); + }; render() { diff --git a/apps/presentationeditor/mobile/src/page/main.jsx b/apps/presentationeditor/mobile/src/page/main.jsx index 2727a2b4c..690cb6f4d 100644 --- a/apps/presentationeditor/mobile/src/page/main.jsx +++ b/apps/presentationeditor/mobile/src/page/main.jsx @@ -30,34 +30,52 @@ class MainPage extends Component { handleClickToOpenOptions = (opts, showOpts) => { ContextMenu.closeContextMenu(); - this.setState(state => { - if ( opts == 'edit' ) - return {editOptionsVisible: true}; - else if ( opts == 'add' ) - return { - addOptionsVisible: true, - addShowOptions: showOpts - }; - else if ( opts == 'settings' ) - return {settingsVisible: true}; - else if ( opts == 'coauth' ) - return {collaborationVisible: true}; - else if ( opts == 'preview' ) - return {previewVisible: true}; - }); + setTimeout(() => { + let opened = false; + const newState = {}; + if ( opts === 'edit' ) { + this.state.editOptionsVisible && (opened = true); + newState.editOptionsVisible = true; + } else if ( opts === 'add' ) { + this.state.addOptionsVisible && (opened = true); + newState.addOptionsVisible = true; + newState.addShowOptions = showOpts; + } else if ( opts === 'settings' ) { + this.state.settingsVisible && (opened = true); + newState.settingsVisible = true; + } else if ( opts === 'coauth' ) { + this.state.collaborationVisible && (opened = true); + newState.collaborationVisible = true; + } else if ( opts === 'preview' ) { + this.state.previewVisible && (opened = true); + newState.previewVisible = true; + } - if ((opts === 'edit' || opts === 'coauth') && Device.phone) { - f7.navbar.hide('.main-navbar'); - } + for (let key in this.state) { + if (this.state[key] && !opened) { + setTimeout(() => { + this.handleClickToOpenOptions(opts, showOpts); + }, 10); + return; + } + } + + if (!opened) { + this.setState(newState); + if ((opts === 'edit' || opts === 'coauth') && Device.phone) { + f7.navbar.hide('.main-navbar'); + } + } + }, 10); }; handleOptionsViewClosed = opts => { - (async () => { - await 1 && this.setState(state => { + setTimeout(() => { + this.setState(state => { if ( opts == 'edit' ) return {editOptionsVisible: false}; else if ( opts == 'add' ) - return {addOptionsVisible: false}; + return {addOptionsVisible: false, addShowOptions: null}; else if ( opts == 'settings' ) return {settingsVisible: false}; else if ( opts == 'coauth' ) @@ -68,7 +86,7 @@ class MainPage extends Component { if ((opts === 'edit' || opts === 'coauth') && Device.phone) { f7.navbar.show('.main-navbar'); } - })(); + }); }; render() { diff --git a/apps/spreadsheeteditor/mobile/src/page/main.jsx b/apps/spreadsheeteditor/mobile/src/page/main.jsx index 9c316b562..ad19718e7 100644 --- a/apps/spreadsheeteditor/mobile/src/page/main.jsx +++ b/apps/spreadsheeteditor/mobile/src/page/main.jsx @@ -32,28 +32,45 @@ class MainPage extends Component { handleClickToOpenOptions = (opts, showOpts) => { f7.popover.close('.document-menu.modal-in', false); - this.setState(state => { - if ( opts == 'edit' ) - return {editOptionsVisible: true}; - else if ( opts == 'add' ) - return { - addOptionsVisible: true, - addShowOptions: showOpts - }; - else if ( opts == 'settings' ) - return {settingsVisible: true}; - else if ( opts == 'coauth' ) - return {collaborationVisible: true}; - }); + setTimeout(() => { + let opened = false; + const newState = {}; + if ( opts === 'edit' ) { + this.state.editOptionsVisible && (opened = true); + newState.editOptionsVisible = true; + } else if ( opts === 'add' ) { + this.state.addOptionsVisible && (opened = true); + newState.addOptionsVisible = true; + newState.addShowOptions = showOpts; + } else if ( opts === 'settings' ) { + this.state.settingsVisible && (opened = true); + newState.settingsVisible = true; + } else if ( opts === 'coauth' ) { + this.state.collaborationVisible && (opened = true); + newState.collaborationVisible = true; + } - if ((opts === 'edit' || opts === 'coauth') && Device.phone) { - f7.navbar.hide('.main-navbar'); - } + for (let key in this.state) { + if (this.state[key] && !opened) { + setTimeout(() => { + this.handleClickToOpenOptions(opts, showOpts); + }, 10); + return; + } + } + + if (!opened) { + this.setState(newState); + if ((opts === 'edit' || opts === 'coauth') && Device.phone) { + f7.navbar.hide('.main-navbar'); + } + } + }, 10); }; handleOptionsViewClosed = opts => { - (async () => { - await 1 && this.setState(state => { + setTimeout(() => { + this.setState(state => { if ( opts == 'edit' ) return {editOptionsVisible: false}; else if ( opts == 'add' ) @@ -66,7 +83,7 @@ class MainPage extends Component { if ((opts === 'edit' || opts === 'coauth') && Device.phone) { f7.navbar.show('.main-navbar'); } - })(); + }, 1); }; render() {