From ffe1dd6f9ffed6aaa161c2a35def8b614cd3b61d Mon Sep 17 00:00:00 2001 From: Fabian Date: Mon, 3 Jun 2019 18:14:19 +0200 Subject: [PATCH] Optimizing Context Menu --- src/components/context.scss | 2 ++ src/components/routes/vault/EntryList.tsx | 12 ++++++++++-- src/components/routes/vaults/Vaults.tsx | 5 +++-- src/notes.ts | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/components/context.scss b/src/components/context.scss index 4787b0b..c613fd9 100644 --- a/src/components/context.scss +++ b/src/components/context.scss @@ -8,6 +8,8 @@ >button { margin: 0; display: block; + background-color: rgb(224, 224, 224); + color: black; } >*:not(:last-child) { diff --git a/src/components/routes/vault/EntryList.tsx b/src/components/routes/vault/EntryList.tsx index 5df4d94..98c66ba 100755 --- a/src/components/routes/vault/EntryList.tsx +++ b/src/components/routes/vault/EntryList.tsx @@ -59,6 +59,15 @@ export default class EntryList extends Component<{ vault: Promise }, { n onContext(evt: MouseEvent, note: BaseNote) { evt.preventDefault(); + evt.stopPropagation(); + + const close = () => { + document.documentElement.removeEventListener("click", close); + this.setState({ context: undefined }); + } + document.documentElement.addEventListener("click", close); + + const shareNote = async () => { let nav = window.navigator as any; if (nav.share !== undefined) { @@ -82,7 +91,6 @@ export default class EntryList extends Component<{ vault: Promise }, { n }).catch(err => { Notifications.sendError(err); }) - } let share; @@ -254,7 +262,7 @@ export default class EntryList extends Component<{ vault: Promise }, { n
this.searchInput = elm} /> -
diff --git a/src/components/routes/vaults/Vaults.tsx b/src/components/routes/vaults/Vaults.tsx index 7aed7ab..d90cedd 100644 --- a/src/components/routes/vaults/Vaults.tsx +++ b/src/components/routes/vaults/Vaults.tsx @@ -127,12 +127,13 @@ export default class VaultsPage extends Page { - window.removeEventListener("click", close); + document.documentElement.removeEventListener("click", close); this.setState({ context: undefined }); } - window.addEventListener("click", close); + document.documentElement.addEventListener("click", close); let deleteb =