Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: improve dialogs user experience

thecodrrc40ce333e2e1
diff --git a/apps/web/src/components/dialogs/confirm.js b/apps/web/src/components/dialogs/confirm.js
index ab6586de9..831718c1e 100644
--- a/apps/web/src/components/dialogs/confirm.js
+++ b/apps/web/src/components/dialogs/confirm.js
@@ -1,12 +1,9 @@
-import React, { useState } from "react";
+import React from "react";
import { Box, Text } from "rebass";
import Dialog, { showDialog } from "./dialog";
import * as Icon from "../icons";
-import Field from "../field";
function Confirm(props) {
- const [isButtonEnabled, setIsButtonEnabled] = useState(!props.confirmWith);
-
return (
<Dialog
isOpen={true}
@@ -17,7 +14,6 @@ function Confirm(props) {
positiveButton={{
text: props.yesText,
onClick: props.onYes,
- disabled: !isButtonEnabled,
}}
negativeButton={
props.noText && { text: props.noText, onClick: props.onNo }
@@ -27,36 +23,12 @@ function Confirm(props) {
<Text as="span" variant="body">
{props.message}
</Text>
- {props.confirmWith && (
- <Field
- autoFocus
- sx={{ mt: 2 }}
- label={
- <>
- Please type
- <Text as="span" color="error" mx={1}>
- {`${props.confirmWith}`}
- </Text>
- to confirm
- </>
- }
- id="confirm"
- name="confirm"
- onChange={(e) => {
- if (e.target.value === props.confirmWith)
- setIsButtonEnabled(true);
- }}
- />
- )}
</Box>
</Dialog>
);
}
-export function confirm(
- icon,
- { title, subtitle, message, yesText, noText, confirmWith }
-) {
+export function confirm(icon, { title, subtitle, message, yesText, noText }) {
return showDialog((perform) => (
<Confirm
title={title}
@@ -64,7 +36,6 @@ export function confirm(
message={message}
yesText={yesText}
noText={noText}
- confirmWith={confirmWith}
icon={icon}
onNo={() => perform(false)}
onYes={() => perform(true)}
@@ -128,22 +99,6 @@ export function showLogoutConfirmation() {
});
}
-export function showAccountDeleteConfirmation(username) {
- return confirm(Icon.Logout, {
- title: `Delete Account?`,
- message: (
- <>
- This action is <b>IRREVERSIBLE</b>. All your data (notes, notebooks,
- tags, pins, favorites) will be <b>permanently deleted</b> with no way of
- recovery.
- </>
- ),
- confirmWith: username,
- yesText: `I understand, delete my account`,
- noText: "Cancel",
- });
-}
-
export function showAccountDeletedNotice() {
return confirm(Icon.Logout, {
title: `Account deleted`,
diff --git a/apps/web/src/components/dialogs/dialog.js b/apps/web/src/components/dialogs/dialog.js
index c13dd8837..097ee3e86 100644
--- a/apps/web/src/components/dialogs/dialog.js
+++ b/apps/web/src/components/dialogs/dialog.js
@@ -17,9 +17,10 @@ function Dialog(props) {
shouldReturnFocusAfterClose
shouldFocusAfterRender
onAfterOpen={(e) => {
+ if (!props.onClose) return;
// we need this work around because ReactModal content spreads over the overlay
const child = e.contentEl.firstElementChild;
- e.contentEl.onclick = function (e) {
+ e.contentEl.onmousedown = function (e) {
if (!e.screenX && !e.screenY) return;
if (
e.x < child.offsetLeft ||
diff --git a/apps/web/src/components/dialogs/logindialog.js b/apps/web/src/components/dialogs/logindialog.js
index e30e771c2..3f19de5b7 100644
--- a/apps/web/src/components/dialogs/logindialog.js
+++ b/apps/web/src/components/dialogs/logindialog.js
@@ -146,6 +146,7 @@ function LoginDialog(props) {
sx={{ mt: 1 }}
/>
<Button
+ type="button"
variant="anchor"
sx={{ alignSelf: "flex-start" }}
onClick={showForgotPasswordDialog}
@@ -153,7 +154,7 @@ function LoginDialog(props) {
Forgot password?
</Button>
{error && <Text variant="error">{error}</Text>}
- <Label mt={1} fontSize="body" alignItems="center">
+ <Label mt={1} fontSize="body" alignItems="center" color="text">
<Checkbox id="remember" name="remember" defaultChecked />
Keep me logged in
</Label>
diff --git a/apps/web/src/components/dialogs/recovery-key-dialog.js b/apps/web/src/components/dialogs/recovery-key-dialog.js
index 1ed8d6941..6b0501f20 100644
--- a/apps/web/src/components/dialogs/recovery-key-dialog.js
+++ b/apps/web/src/components/dialogs/recovery-key-dialog.js
@@ -21,7 +21,7 @@ function RecoveryKeyDialog(props) {
})();
}, []);
return (
- <Dialog isOpen={true} title="Backup Recovery Key" onClose={props.onDone}>
+ <Dialog isOpen={true} title="Backup Recovery Key">
<Flex flexDirection="column" flex={1} sx={{ overflow: "hidden" }}>
<Flex flexDirection="column" sx={{ overflowY: "auto" }}>
<Text