Skip to content

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

mobile: show title is required error under the input

Ammar Ahmedaf08ed51740d
diff --git a/apps/mobile/app/screens/add-reminder/index.tsx b/apps/mobile/app/screens/add-reminder/index.tsx
index 5cb054d17..5383a6f36 100644
--- a/apps/mobile/app/screens/add-reminder/index.tsx
+++ b/apps/mobile/app/screens/add-reminder/index.tsx
@@ -59,6 +59,10 @@ import { TimeSince } from "../../components/ui/time-since";
import Heading from "../../components/ui/typography/heading";
import { eOnLoadNote } from "../../utils/events";
import { fluidTabsRef } from "../../utils/global-refs";
+import FormInput, {
+ createFormRef,
+ validators
+} from "../../components/ui/input/form-input";
const ReminderModes =
Platform.OS === "ios"
@@ -113,7 +117,12 @@ export default function AddReminder(props: NavigationProps<"AddReminder">) {
const [repeatFrequency, setRepeatFrequency] = useState(1);
const referencedItem = reference ? (reference as Note) : null;
const recurringReminderFeature = useIsFeatureAvailable("recurringReminders");
-
+ const formRef = useRef(
+ createFormRef({
+ title: reminder?.title || referencedItem?.title || "",
+ description: reminder?.description || referencedItem?.headline || ""
+ })
+ );
const title = useRef<string | undefined>(
!reminder ? referencedItem?.title : reminder?.title
);
@@ -172,7 +181,7 @@ export default function AddReminder(props: NavigationProps<"AddReminder">) {
async function saveReminder() {
try {
- if (!title.current?.trim()) throw new Error(strings.setTitleError());
+ if (!formRef.current.validate()) return;
if (
date.getTime() < Date.now() &&
reminderMode === "once" &&
@@ -262,7 +271,10 @@ export default function AddReminder(props: NavigationProps<"AddReminder">) {
keyboardDismissMode="interactive"
keyboardShouldPersistTaps="handled"
>
- <Input
+ <FormInput
+ name="title"
+ validators={[validators.required(strings.titleIsRequired())]}
+ formRef={formRef}
fwdRef={titleRef}
defaultValue={reminder?.title || referencedItem?.title}
placeholder={strings.remindeMeOf()}
@@ -271,12 +283,15 @@ export default function AddReminder(props: NavigationProps<"AddReminder">) {
wrapperStyle={{
marginTop: DefaultAppStyles.GAP_VERTICAL
}}
- onSubmit={() => {
+ onSubmitEditing={() => {
descriptionRef.current?.focus();
}}
/>
- <Input
+ <FormInput
+ name="description"
+ validators={[]}
+ formRef={formRef}
defaultValue={
reminder ? reminder?.description : referencedItem?.headline
}
diff --git a/packages/intl/locale/en.po b/packages/intl/locale/en.po
index 22077ef22..6499ba0ea 100644
--- a/packages/intl/locale/en.po
+++ b/packages/intl/locale/en.po
@@ -992,7 +992,7 @@ msgstr "attachment"
msgid "Attachment"
msgstr "Attachment"
-#: src/strings.ts:2663
+#: src/strings.ts:2667
msgid "Attachment deleted"
msgstr "Attachment deleted"
@@ -6664,6 +6664,10 @@ msgstr "Title"
msgid "Title format"
msgstr "Title format"
+#: src/strings.ts:2668
+msgid "Title is required"
+msgstr "Title is required"
+
#: src/strings.ts:1188
msgid "To use app lock, you must enable biometrics such as Fingerprint lock or Face ID on your phone."
msgstr "To use app lock, you must enable biometrics such as Fingerprint lock or Face ID on your phone."
diff --git a/packages/intl/locale/pseudo-LOCALE.po b/packages/intl/locale/pseudo-LOCALE.po
index 76ee7a81b..add9f914c 100644
--- a/packages/intl/locale/pseudo-LOCALE.po
+++ b/packages/intl/locale/pseudo-LOCALE.po
@@ -992,7 +992,7 @@ msgstr ""
msgid "Attachment"
msgstr ""
-#: src/strings.ts:2663
+#: src/strings.ts:2667
msgid "Attachment deleted"
msgstr ""
@@ -6623,6 +6623,10 @@ msgstr ""
msgid "Title format"
msgstr ""
+#: src/strings.ts:2668
+msgid "Title is required"
+msgstr ""
+
#: src/strings.ts:1188
msgid "To use app lock, you must enable biometrics such as Fingerprint lock or Face ID on your phone."
msgstr ""
diff --git a/packages/intl/src/strings.ts b/packages/intl/src/strings.ts
index 927e7be4e..472ef36c3 100644
--- a/packages/intl/src/strings.ts
+++ b/packages/intl/src/strings.ts
@@ -2664,5 +2664,6 @@ Use this if changes from other devices are not appearing on this device. This wi
deleteAttachment: () => t`Delete attachment`,
deleteAttachmentConfirm: () =>
t`Are you sure you want to delete this attachment?`,
- attachmentDeleted: () => t`Attachment deleted`
+ attachmentDeleted: () => t`Attachment deleted`,
+ titleIsRequired: () => t`Title is required`
};