Skip to content

Commit

Permalink
fix(front): fix provider access error
Browse files Browse the repository at this point in the history
  • Loading branch information
SARDONYX-sard committed Nov 11, 2024
1 parent 825e079 commit 4700f54
Show file tree
Hide file tree
Showing 4 changed files with 466 additions and 681 deletions.
17 changes: 13 additions & 4 deletions gui/frontend/src/components/organisms/ConvertForm/ConvertForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ export function ConvertForm() {
});
};

const pathFields = useInputPathFields();
const modInfoFields = useModInfoFields();
const checkFields = useCheckFields();

Expand All @@ -114,9 +113,7 @@ export function ConvertForm() {
{t('all-clear-btn')}
</Button>

{pathFields.map((props) => {
return <InputPathField key={props.name} {...props} />;
})}
<InputPathFields />

<Grid columnSpacing={1} container={true} gap={2} sx={{ width: '100%' }}>
{modInfoFields.map((props) => {
Expand All @@ -139,3 +136,15 @@ export function ConvertForm() {
</FormProvider>
);
}

// NOTE: It is necessary to call `useFormContext` in `FormProvider` since it is called internally.
// This avoids the wrapper component wrapping inaccessibility error.
const InputPathFields = () => {
const pathFields = useInputPathFields();

return (
pathFields.map((props) => {
return <InputPathField key={props.name} {...props} />
})
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { FormProps } from './ConvertForm';
import type { InputPathField } from './InputPathField';
import type { ComponentPropsWithRef } from 'react';

/** NOTE: Must be called in `FormProvider` as it calls `useFormContext` internally */
export const useInputPathFields = () => {
const { t } = useTranslation();
const { setValue, getValues } = useFormContext<FormProps>();
Expand Down
Loading

0 comments on commit 4700f54

Please sign in to comment.