Skip to content

Commit

Permalink
Merge pull request #1685 from sophieturner0/Required-Properties-Next-…
Browse files Browse the repository at this point in the history
…Button-Should-Not-Allow

Disable 'Next' Button on Empty Spaces in 'Required Properties' [ChangeNodeTypeModal]
  • Loading branch information
Rassl authored Jul 23, 2024
2 parents 37ab141 + 79ec453 commit 38a283d
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { getNodeType } from '~/network/fetchSourcesData'
import { colors } from '~/utils'
import { MapNodeTypeModalStepID, SelectedValues } from '..'
import { parseJson, parsedObjProps } from '../../BlueprintModal/Body/Editor/utils'
import { noSpacePattern } from '~/components/AddItemModal/SourceTypeStep/constants'

type Props = {
skipToStep: (step: MapNodeTypeModalStepID) => void
Expand Down Expand Up @@ -75,6 +76,9 @@ export const RequiredPropertiesStep: FC<Props> = ({ handleSelectType, skipToStep
skipToStep('sourceType')
}

const isNextDisabled =
!isValid || loading || filteredAttributes.some((attr) => attr.required && !watch(attr.key)?.trim())

return (
<Flex>
<Flex align="center" direction="row" justify="space-between" mb={18}>
Expand All @@ -100,7 +104,15 @@ export const RequiredPropertiesStep: FC<Props> = ({ handleSelectType, skipToStep
name={key}
placeholder={required ? 'Required' : 'Optional'}
rules={{
...(required ? requiredRule : {}),
...(required
? {
...requiredRule,
pattern: {
message: 'No leading whitespace allowed',
value: noSpacePattern,
},
}
: {}),
}}
/>
</TextFieldWrapper>
Expand All @@ -119,7 +131,7 @@ export const RequiredPropertiesStep: FC<Props> = ({ handleSelectType, skipToStep
<Flex grow={1} ml={20}>
<Button
color="secondary"
disabled={!isValid || loading || filteredAttributes?.some((attr) => attr.required && !watch(attr.key))}
disabled={isNextDisabled}
onClick={() => skipToStep('createConfirmation')}
size="large"
variant="contained"
Expand Down

0 comments on commit 38a283d

Please sign in to comment.