diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2024-01-30 16:21:03 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2024-01-31 11:45:29 +0100 |
| commit | fc779b4ddad22658b95b262ff6e04396ebb6a0bc (patch) | |
| tree | 63b30906ab15cd23c0863014b3ac3bd3d0edbc2e /gui | |
| parent | ae9ed260d829ef3460b72018f8e52efcf1e5885d (diff) | |
| download | mullvadvpn-fc779b4ddad22658b95b262ff6e04396ebb6a0bc.tar.xz mullvadvpn-fc779b4ddad22658b95b262ff6e04396ebb6a0bc.zip | |
Fix name not updating when editing list
Diffstat (limited to 'gui')
| -rw-r--r-- | gui/src/renderer/components/EditApiAccessMethod.tsx | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/gui/src/renderer/components/EditApiAccessMethod.tsx b/gui/src/renderer/components/EditApiAccessMethod.tsx index f60646ab36..c56329214b 100644 --- a/gui/src/renderer/components/EditApiAccessMethod.tsx +++ b/gui/src/renderer/components/EditApiAccessMethod.tsx @@ -280,15 +280,31 @@ function AccessMethodFormImpl(props: EditApiAccessMethodImplProps) { // State for the name input. const name = useRef(props.method?.name ?? ''); - const updateName = useCallback((value: string) => (name.current = value), []); + const method = useRef<AccessMethod | undefined>(props.method); // When the form makes up a valid method the parent is updated. - const updateMethod = useCallback((value: AccessMethod) => { - if (name.current !== '') { - props.updateMethod({ ...value, name: name.current, enabled: true }); + const onUpdate = useCallback(() => { + if (method.current !== undefined && name.current !== '') { + props.updateMethod({ ...method.current, name: name.current, enabled: true }); } }, []); + const updateName = useCallback( + (value: string) => { + name.current = value; + onUpdate(); + }, + [onUpdate], + ); + + const updateMethod = useCallback( + (value: AccessMethod) => { + method.current = value; + onUpdate(); + }, + [onUpdate], + ); + return ( <> <SettingsRow label={messages.gettext('Name')}> |
