Skip to content

Commit

Permalink
Adding isClearable back in
Browse files Browse the repository at this point in the history
  • Loading branch information
7emansell committed Dec 20, 2024
1 parent 35568c6 commit 91f41a5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/MyAccount/Settings/PasswordForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const PasswordFormField = forwardRef<TextInputRefType, PasswordFormFieldProps>(
onChange={handler}
invalidText="Pin/passwords do not match."
isInvalid={isInvalid}
isClearable
/>
</Flex>
)
Expand Down
13 changes: 11 additions & 2 deletions src/components/MyAccount/Settings/SettingsInputForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ const SettingsInputForm = ({
updatedInputs[index] = value
setTempInputs(updatedInputs)

const firstInputEmpty = index === 0
const firstInput = index === 0

if (firstInputEmpty && (!value || !validateInput(value, updatedInputs))) {
if (firstInput && (!value || !validateInput(value, updatedInputs))) {
setError(true)
} else {
const hasInvalidInput = updatedInputs.some(
Expand Down Expand Up @@ -127,6 +127,13 @@ const SettingsInputForm = ({
setError(hasInvalidInput)
}

const handleClearableCallback = (index) => {
const updatedInputs = [...tempInputs]
updatedInputs[index] = ""
setTempInputs(updatedInputs)
setError(true)
}

const cancelEditing = () => {
setTempInputs([...inputs])
setIsEditing(false)
Expand Down Expand Up @@ -224,6 +231,8 @@ const SettingsInputForm = ({
invalidText={formUtils.errorMessage}
onChange={(e) => handleInputChange(e, index)}
isRequired
isClearable
isClearableCallback={() => handleClearableCallback(index)}
/>
{index == 0 && <div style={{ width: "57px" }}> </div>}
{index !== 0 && (
Expand Down
2 changes: 2 additions & 0 deletions src/components/MyAccount/Settings/UsernameForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ const UsernameForm = ({ patron, usernameState }: UsernameFormProps) => {
isInvalid={error && !validateUsername(tempUsername)}
showHelperInvalidText={true}
onChange={handleInputChange}
isClearable
isClearableCallback={() => setError(true)}
/>
<Button
aria-label="Delete username from your account"
Expand Down

0 comments on commit 91f41a5

Please sign in to comment.