[i18n] add filters from the start (#9796)

This commit is contained in:
Marvin Frachet 2021-03-22 10:59:03 +01:00 committed by GitHub
parent 932da387be
commit e293243da9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Label } from '@buffetjs/core';
import { Inputs } from '@buffetjs/custom';
import Select from 'react-select';
import Select, { createFilter } from 'react-select';
import { Col, Row } from 'reactstrap';
import { useIntl } from 'react-intl';
import { useTheme } from 'styled-components';
@ -10,6 +10,12 @@ import { BaselineAlignment, selectStyles, DropdownIndicator } from 'strapi-helpe
import { useFormikContext } from 'formik';
import { getTrad } from '../../utils';
const reactSelectLocaleFilter = createFilter({
ignoreCase: true,
ignoreAccents: true,
matchFrom: 'start',
});
const BaseForm = ({ options, defaultOption }) => {
const theme = useTheme();
const { formatMessage } = useIntl();
@ -34,6 +40,7 @@ const BaseForm = ({ options, defaultOption }) => {
aria-labelledby="locale-code"
options={options}
defaultValue={defaultOption}
filterOption={reactSelectLocaleFilter}
onChange={selection => {
setFieldValue('displayName', selection.value);
setFieldValue('code', selection.label);