Skip to content

Commit

Permalink
use form default locale for language select field default
Browse files Browse the repository at this point in the history
  • Loading branch information
mirekys committed Nov 3, 2023
1 parent e6ee6f1 commit f872206
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FieldLabel } from "react-invenio-forms";
import { LocalVocabularySelectField } from "@js/oarepo_vocabularies";
import { i18next } from "@translations/oarepo_ui/i18next";
import PropTypes from "prop-types";
import { useFormConfig } from "@js/oarepo_ui";

export const LanguageSelectField = ({
fieldPath,
Expand All @@ -16,6 +17,10 @@ export const LanguageSelectField = ({
value,
...uiProps
}) => {
const {
formConfig: { default_locale },
} = useFormConfig();

return (
<LocalVocabularySelectField
deburr
Expand All @@ -30,7 +35,7 @@ export const LanguageSelectField = ({
onChange={({ e, data, formikProps }) => {
formikProps.form.setFieldValue(fieldPath, data.value);
}}
defaultValue="en"
defaultValue={multiple ? [default_locale] : default_locale}
{...uiProps}
/>
);
Expand Down

0 comments on commit f872206

Please sign in to comment.