Skip to content

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

mobile: show errors under input in rename dialog

Ammar Ahmede7fb246c257d
diff --git a/apps/mobile/app/components/attachments/actions.tsx b/apps/mobile/app/components/attachments/actions.tsx
index 84a07e74a..4ee2de59e 100644
--- a/apps/mobile/app/components/attachments/actions.tsx
+++ b/apps/mobile/app/components/attachments/actions.tsx
@@ -22,7 +22,7 @@ import { Attachment, Note, VirtualizedGrouping } from "@notesnook/core";
import { useThemeColors } from "@notesnook/theme";
import Clipboard from "@react-native-clipboard/clipboard";
import React, { RefObject, useEffect, useState } from "react";
-import { View } from "react-native";
+import { TextInput, View } from "react-native";
import { ActionSheetRef } from "react-native-actions-sheet";
import { ScrollView } from "react-native-gesture-handler";
import { db } from "../../common/database";
@@ -59,6 +59,7 @@ import Paragraph from "../ui/typography/paragraph";
import { strings } from "@notesnook/intl";
import { DefaultAppStyles } from "../../utils/styles";
import Navigation from "../../services/navigation";
+import { createFormRef, validators } from "../ui/input/form-input";
const Actions = ({
attachment,
@@ -156,31 +157,40 @@ const Actions = ({
close?.();
setTimeout(() => {
presentDialog({
- input: true,
- inputPlaceholder: strings.enterTitle(),
title: strings.renameFile(),
- defaultValue: attachment.filename,
- positivePress: async (value) => {
- try {
- if (!value || !value.trim()) {
- throw new Error(strings.nameIsRequired());
+ form: {
+ formRef: createFormRef({
+ name: attachment.filename
+ }),
+ items: [
+ {
+ name: "name",
+ defaultValue: attachment.filename,
+ placeholder: strings.enterTitle(),
+ ref: React.createRef<TextInput | null>(),
+ validators: [validators.required(strings.nameIsRequired())]
}
- await db.attachments.add({
- hash: attachment.hash,
- filename: value
- });
- setFilename(value);
- setAttachments();
- eSendEvent(eDBItemUpdate, attachment.id);
- ToastManager.show({
- message: `Attachment renamed to ${value}`,
- type: "success"
- });
+ ],
+ onFormSubmit: async (form) => {
+ try {
+ const value = form.getValue("name");
+ await db.attachments.add({
+ hash: attachment.hash,
+ filename: value
+ });
+ setFilename(value);
+ setAttachments();
+ eSendEvent(eDBItemUpdate, attachment.id);
+ ToastManager.show({
+ message: `Attachment renamed to ${value}`,
+ type: "success"
+ });
- return true;
- } catch (e) {
- ToastManager.error(e as Error, undefined, "local");
- return false;
+ return true;
+ } catch (e) {
+ form.setError("name", (e as Error).message);
+ return false;
+ }
}
},
positiveText: strings.rename()
diff --git a/packages/intl/locale/en.po b/packages/intl/locale/en.po
index 09fe8f1e1..534e7e949 100644
--- a/packages/intl/locale/en.po
+++ b/packages/intl/locale/en.po
@@ -1,17 +1,11 @@
msgid ""
msgstr ""
-"POT-Creation-Date: 2026-04-20 11:33+0500\n"
+"POT-Creation-Date: 2026-05-08 10:43+0500\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: @lingui/cli\n"
"Language: en\n"
-"Project-Id-Version: \n"
-"Report-Msgid-Bugs-To: \n"
-"PO-Revision-Date: \n"
-"Last-Translator: \n"
-"Language-Team: \n"
-"Plural-Forms: \n"
#: src/strings.ts:2421
msgid " \"Notebook > Notes\""
diff --git a/packages/intl/locale/pseudo-LOCALE.po b/packages/intl/locale/pseudo-LOCALE.po
index ab3f66ba2..0ad2efe05 100644
--- a/packages/intl/locale/pseudo-LOCALE.po
+++ b/packages/intl/locale/pseudo-LOCALE.po
@@ -1,17 +1,11 @@
msgid ""
msgstr ""
-"POT-Creation-Date: 2026-04-20 11:33+0500\n"
+"POT-Creation-Date: 2026-05-08 10:43+0500\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: @lingui/cli\n"
"Language: pseudo-LOCALE\n"
-"Project-Id-Version: \n"
-"Report-Msgid-Bugs-To: \n"
-"PO-Revision-Date: \n"
-"Last-Translator: \n"
-"Language-Team: \n"
-"Plural-Forms: \n"
#: src/strings.ts:2421
msgid " \"Notebook > Notes\""