From 0f472cab92f4069b0d5330cd1f71f013ece98fb1 Mon Sep 17 00:00:00 2001 From: Sophie Turner Date: Fri, 26 Jul 2024 19:12:15 +0500 Subject: [PATCH] fix(blueprint-modal): confirm button should not allow enable with empty spaces --- .../BlueprintModal/Body/AddEdgeNode/Body/index.tsx | 10 +++++----- .../BlueprintModal/Body/AddEdgeNode/Title/index.tsx | 7 ++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/ModalsContainer/BlueprintModal/Body/AddEdgeNode/Body/index.tsx b/src/components/ModalsContainer/BlueprintModal/Body/AddEdgeNode/Body/index.tsx index dca2c7dcc..82717e298 100644 --- a/src/components/ModalsContainer/BlueprintModal/Body/AddEdgeNode/Body/index.tsx +++ b/src/components/ModalsContainer/BlueprintModal/Body/AddEdgeNode/Body/index.tsx @@ -1,12 +1,12 @@ import { Button } from '@mui/material' -import { useState, useEffect } from 'react' +import { useEffect, useState } from 'react' import { FormProvider, useForm } from 'react-hook-form' import { ClipLoader } from 'react-spinners' -import { colors } from '~/utils/colors' -import { TitleEditor } from '../Title' import styled from 'styled-components' -import { deleteEdgeType, postBluePrintType, updateEdgeType, getNodeSchemaTypes } from '~/network/fetchSourcesData' import { Flex } from '~/components/common/Flex' +import { deleteEdgeType, getNodeSchemaTypes, postBluePrintType, updateEdgeType } from '~/network/fetchSourcesData' +import { colors } from '~/utils/colors' +import { TitleEditor } from '../Title' export type FormData = { type: string @@ -90,7 +90,7 @@ export const Body = ({ onCancel, edgeLinkData, setGraphLoading }: Props) => { const submitDisabled = edgeLinkData?.refId ? loading || !isEdgeLinkChange - : loading || !selectedToNode || !selectedFromNode || !selectedType + : loading || !selectedToNode.trim() || !selectedFromNode.trim() || !selectedType.trim() const handleDelete = async () => { setOnDeleteLoading(true) diff --git a/src/components/ModalsContainer/BlueprintModal/Body/AddEdgeNode/Title/index.tsx b/src/components/ModalsContainer/BlueprintModal/Body/AddEdgeNode/Title/index.tsx index 7990500c6..834b7a1a5 100644 --- a/src/components/ModalsContainer/BlueprintModal/Body/AddEdgeNode/Title/index.tsx +++ b/src/components/ModalsContainer/BlueprintModal/Body/AddEdgeNode/Title/index.tsx @@ -1,10 +1,11 @@ import { FC } from 'react' import styled from 'styled-components' +import { noSpacePattern } from '~/components/AddItemModal/SourceTypeStep/constants' import { Flex } from '~/components/common/Flex' import { Text } from '~/components/common/Text' -import { ToNode } from './ToNode' import { TextInput } from '~/components/common/TextInput' import { requiredRule } from '~/constants' +import { ToNode } from './ToNode' type Props = { selectedType: string @@ -58,6 +59,10 @@ export const TitleEditor: FC = ({ placeholder="Enter type name" rules={{ ...requiredRule, + pattern: { + message: 'No leading whitespace allowed', + value: noSpacePattern, + }, }} value={selectedType} />