Skip to content

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

mobile: fix loading indicator causes cancel button to jump

Ammar Ahmedd4d7eac2403c
diff --git a/apps/mobile/app/components/dialog/dialog-buttons.tsx b/apps/mobile/app/components/dialog/dialog-buttons.tsx
index fd055abfd..01e8d1efb 100644
--- a/apps/mobile/app/components/dialog/dialog-buttons.tsx
+++ b/apps/mobile/app/components/dialog/dialog-buttons.tsx
@@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import { strings } from "@notesnook/intl";
import { useThemeColors } from "@notesnook/theme";
import React from "react";
-import { StyleSheet, View } from "react-native";
+import { ActivityIndicator, StyleSheet, View } from "react-native";
import Icon from "react-native-vector-icons/MaterialCommunityIcons";
import { notesnook } from "../../../e2e/test.ids";
import { getColorLinearShade } from "../../utils/colors";
@@ -79,6 +79,11 @@ const DialogButtons = ({
/>
<Paragraph color={colors.primary.accent}>{" " + doneText}</Paragraph>
</View>
+ ) : loading ? (
+ <ActivityIndicator
+ size={AppFontSize.lg}
+ color={colors.primary.accent}
+ />
) : (
<View />
)}
@@ -105,7 +110,6 @@ const DialogButtons = ({
style={{
marginLeft: 10
}}
- loading={loading}
bold
type={positiveType || "transparent"}
title={positiveTitle}
diff --git a/apps/mobile/app/components/dialog/index.tsx b/apps/mobile/app/components/dialog/index.tsx
index b3ebd16d3..c4e6a1080 100644
--- a/apps/mobile/app/components/dialog/index.tsx
+++ b/apps/mobile/app/components/dialog/index.tsx
@@ -67,15 +67,13 @@ export const Dialog = ({ context = "global" }: { context?: string }) => {
// Handle form submission if form is available
if (dialogInfo?.form && formRef.current) {
inputRef.current?.blur();
- setLoading(true);
try {
const isValid = await formRef.current.validate();
if (!isValid) {
- setLoading(false);
return;
}
-
if (dialogInfo.form.onFormSubmit) {
+ setLoading(true);
const result = await dialogInfo.form.onFormSubmit(formRef.current);
if (result === false) {
setLoading(false);