From 20c7c145676c319a7a9dccfc9c4dc45c1c1b0462 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 15 Jan 2021 16:34:53 +0100 Subject: [PATCH] Bug Fixed:Not exiting edit mode when user types command --- .../Superalgos/UI/Spaces/Docs-Space/ContextMenu.js | 14 +++++++------- .../UI/Spaces/Docs-Space/DocumentPage.js | 2 +- .../UI/Spaces/Docs-Space/MainSearchPage.js | 7 ++++--- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/ContextMenu.js b/Projects/Superalgos/UI/Spaces/Docs-Space/ContextMenu.js index 8614e01a2..99d4f8ce3 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/ContextMenu.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/ContextMenu.js @@ -2,7 +2,7 @@ function newSuperalgosDocsContextMenu() { let thisObject = { selectedParagraph: undefined, getSelection: getSelection, - forceOutClick: forceOutClick, + removeContextMenuFromScreen: removeContextMenuFromScreen, initialize: initialize, finalize: finalize } @@ -53,7 +53,7 @@ function newSuperalgosDocsContextMenu() { } function editParagraph() { - forceOutClick() + removeContextMenuFromScreen() showHTMLTextArea() function showHTMLTextArea() { @@ -107,7 +107,7 @@ function newSuperalgosDocsContextMenu() { UI.projects.superalgos.spaces.docsSpace.contextMenu.selectedParagraph.appendChild(UI.projects.superalgos.spaces.docsSpace.textArea) UI.projects.superalgos.spaces.docsSpace.textArea.style.display = 'block' UI.projects.superalgos.spaces.docsSpace.textArea.focus() - forceOutClick() + removeContextMenuFromScreen() UI.projects.superalgos.spaces.docsSpace.enterEditMode() } } @@ -116,7 +116,7 @@ function newSuperalgosDocsContextMenu() { if (selectedParagraphIndex === undefined) { return } if (selectedParagraphIndex === 0) { return } UI.projects.superalgos.spaces.docsSpace.documentPage.docsSchemaDocument.paragraphs.splice(selectedParagraphIndex, 1) - forceOutClick() + removeContextMenuFromScreen() UI.projects.superalgos.spaces.docsSpace.documentPage.docsSchemaDocument.updated = true UI.projects.superalgos.spaces.docsSpace.documentPage.render() } @@ -260,20 +260,20 @@ function newSuperalgosDocsContextMenu() { } UI.projects.superalgos.utilities.clipboard.copyTextToClipboard(clipboard) - forceOutClick() + removeContextMenuFromScreen() } function replaceStyle(docSchemaParagraph, style) { if (docSchemaParagraph.style !== style) { UI.projects.superalgos.spaces.docsSpace.documentPage.docsSchemaDocument.updated = true docSchemaParagraph.style = style - forceOutClick() + removeContextMenuFromScreen() UI.projects.superalgos.spaces.docsSpace.documentPage.render() } } } - function forceOutClick() { + function removeContextMenuFromScreen() { const outClick = document.getElementById('docs-space-div') const menu = document.getElementById('menu') menu.classList.remove('show') diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js index cd9423cf1..10b06f8c9 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js @@ -1933,7 +1933,7 @@ function newSuperalgosDocsDocumentPage() { outClick.addEventListener('click', () => { if (EDITOR_ON_FOCUS !== true) { - UI.projects.superalgos.spaces.docsSpace.contextMenu.forceOutClick() + UI.projects.superalgos.spaces.docsSpace.contextMenu.removeContextMenuFromScreen() } }) } diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/MainSearchPage.js b/Projects/Superalgos/UI/Spaces/Docs-Space/MainSearchPage.js index 5b652eb47..467185d54 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/MainSearchPage.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/MainSearchPage.js @@ -1,9 +1,9 @@ function newSuperalgosDocsMainSearchPage() { let thisObject = { - addSearchHeader: addSearchHeader, + addSearchHeader: addSearchHeader, detectEnterOnSearchBox: detectEnterOnSearchBox, setFocusOnSearchBox: setFocusOnSearchBox, - render: render, + render: render, initialize: initialize, finalize: finalize } @@ -51,8 +51,9 @@ function newSuperalgosDocsMainSearchPage() { } element.addEventListener("keyup", function (event) { if (event.key === "Enter" || event.keyCode === 13) { + UI.projects.superalgos.spaces.docsSpace.exitEditMode() UI.projects.superalgos.spaces.docsSpace.currentBookBeingRendered = undefined - UI.projects.superalgos.spaces.docsSpace.contextMenu.forceOutClick() + UI.projects.superalgos.spaces.docsSpace.contextMenu.removeContextMenuFromScreen() UI.projects.superalgos.spaces.docsSpace.commandInterface.command = element.value.trim() UI.projects.superalgos.spaces.docsSpace.commandInterface.detectCommands() }