Skip to content

Commit

Permalink
fix(ui): initial value for CityField was not working
Browse files Browse the repository at this point in the history
  • Loading branch information
sneko committed Oct 16, 2023
1 parent 8dc34bc commit fee7f4d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,7 @@ export function CasePage({ params: { authorityId, caseId } }: CasePageProps) {
</Grid>
<Grid item xs={12} sm={6}>
<CityField
initialValue={control._defaultValues.address?.city}
suggestionsPostalCode={watch('address.postalCode')}
workaroundSetValue={(newValue) => {
setValue('address.city', newValue || '', {
Expand Down
4 changes: 2 additions & 2 deletions apps/main/src/components/CityField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import Autocomplete from '@mui/material/Autocomplete';
import TextField, { TextFieldProps } from '@mui/material/TextField';
import debounce from 'lodash.debounce';
import { PropsWithChildren, useEffect, useMemo, useRef, useState } from 'react';
import { UseFormSetValue } from 'react-hook-form';

import { LocationApiProperties, searchCitiesByPostalCode } from '@mediature/main/src/utils/national-address-base';

export interface CityFieldProps {
initialValue?: string;
textFieldProps: TextFieldProps;
workaroundSetValue?: (newValue: string | null) => void;
suggestionsPostalCode?: string;
Expand Down Expand Up @@ -46,7 +46,7 @@ export function CityField(props: PropsWithChildren<CityFieldProps>) {

return (
<Autocomplete
value={undefined}
value={props.initialValue}
options={searchCityQuerySuggestions.map((suggestion): string => {
return suggestion.city;
})}
Expand Down

0 comments on commit fee7f4d

Please sign in to comment.