A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
web: close publish popup on focus lost
Abdullah Atta34bf9d5b4585
diff --git a/apps/web/src/components/publish-view/index.js b/apps/web/src/components/publish-view/index.jsindex 8a3fa5dda..872c405ce 100644--- a/apps/web/src/components/publish-view/index.js+++ b/apps/web/src/components/publish-view/index.js@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.*/-import { useEffect, useMemo, useState } from "react";+import { useCallback, useEffect, useMemo, useState } from "react";import ReactDOM from "react-dom";import { Flex, Text, Button } from "@theme-ui/components";import * as Icon from "../icons";@@ -29,7 +29,6 @@ import ThemeProvider from "../theme-provider";import { showToast } from "../../utils/toast";import { EV, EVENTS } from "@notesnook/core/common";import { useStore } from "../../stores/monograph-store";-import { closeOpenedDialog } from "../../common/dialog-controller";function PublishView(props) {const { noteId, position, onClose } = props;@@ -47,6 +46,15 @@ function PublishView(props) {setPublishId(db.monographs.monograph(noteId));}, [noteId]);+ const onKeyDown = useCallback(+ (event) => {+ if (event.keyCode === 27) onClose(false);+ },+ [onClose]+ );++ const onWindowClick = useCallback(() => onClose(false), [onClose]);+useEffect(() => {window.addEventListener("keydown", onKeyDown);window.addEventListener("click", onWindowClick);@@ -57,7 +65,7 @@ function PublishView(props) {window.removeEventListener("keydown", onKeyDown);window.removeEventListener("blur", onWindowClick);};- }, []);+ }, [onKeyDown, onWindowClick]);useEffect(() => {const attachmentsLoadingEvent = EV.subscribe(@@ -304,6 +312,7 @@ export function showPublishView(noteId, location = "top") {return new Promise((resolve) => {const perform = (result) => {ReactDOM.unmountComponentAtNode(root);+ closePublishView();resolve(result);};ReactDOM.render(@@ -326,10 +335,9 @@ export function showPublishView(noteId, location = "top") {return Promise.reject("No element with id 'dialogContainer'");}-function onKeyDown(event) {- if (event.keyCode === 27) closeOpenedDialog();-}--function onWindowClick() {- closeOpenedDialog();+function closePublishView() {+ const root = document.getElementById("dialogContainer");+ if (root) {+ root.innerHTML = "";+ }}