Skip to content

Commit 2ad72a5

Browse files
fix(admin-ui): correct Cancel button behavior in Jans Lock page to re… (#2369)
* fix(admin-ui): correct Cancel button behavior in Jans Lock page to reset form values properly * fix(admin-ui): token channel field now resetting successfully --------- Signed-off-by: Faisal Siddique <71010439+faisalsiddique4400@users.noreply.github.com>
1 parent aabd989 commit 2ad72a5

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

admin-ui/plugins/jans-lock/components/JansLockConfiguration.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
jansLockConstants,
1616
} from '../helper'
1717
import { JansLockConfigFormValues, PatchOperation } from '../types'
18+
import { trimObjectStrings } from 'Utils/Util'
1819

1920
interface JansLockConfigurationProps {
2021
lockConfig: Record<string, unknown>
@@ -49,9 +50,16 @@ const JansLockConfiguration: React.FC<JansLockConfigurationProps> = ({ lockConfi
4950
validationSchema,
5051
})
5152

53+
const handleCancel = useCallback(() => {
54+
formik.resetForm()
55+
}, [formik])
56+
5257
const submitForm = useCallback(
5358
(userMessage: string) => {
54-
const patchOperations = createPatchOperations(formik.values, lockConfig)
59+
const trimmedValues = trimObjectStrings(
60+
formik.values as unknown as Record<string, unknown>,
61+
) as unknown as JansLockConfigFormValues
62+
const patchOperations = createPatchOperations(trimmedValues, lockConfig)
5563

5664
toggle()
5765

@@ -398,7 +406,9 @@ const JansLockConfiguration: React.FC<JansLockConfigurationProps> = ({ lockConfi
398406
<Col>
399407
<GluuCommitFooter
400408
saveHandler={toggle}
401-
hideButtons={{ save: true, back: false }}
409+
hideButtons={{ save: true, back: true }}
410+
extraLabel="Cancel"
411+
extraOnClick={handleCancel}
402412
type="submit"
403413
/>
404414
</Col>

0 commit comments

Comments
 (0)