Merge branch 'master' into develop

This commit is contained in:
Alexandre Bodin 2019-11-04 10:25:16 +01:00
commit 12260bae16
3 changed files with 36 additions and 17 deletions

View File

@ -103,7 +103,7 @@ Limit the result length to 30.
`GET /users?_limit=30`
You can require the full data set by passing a limit equal to `-1`
You can require the full data set by passing a limit equal to `0`
### Start

View File

@ -4,7 +4,7 @@ Upgrading your Strapi application to `v3.0.0-beta.17.4`.
## Upgrading your dependencies
Start by upgrading your dependencies. Make sur to use exact versions.
Start by upgrading your dependencies. Make sure to use exact versions.
::: danger
`strapi-plugin-settings-manager` has been deprecated. you need to remove it from your `package.json`.

View File

@ -2,7 +2,7 @@ import React, { useState, useEffect, useRef, memo } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';
import { Link } from 'react-router-dom';
import { isArray, isEmpty } from 'lodash';
import { isArray, isEmpty, cloneDeep } from 'lodash';
import { request } from 'strapi-helper-plugin';
import pluginId from '../../pluginId';
@ -41,12 +41,15 @@ function SelectWrapper({
});
const [options, setOptions] = useState([]);
const [isLoading, setIsLoading] = useState(true);
const abortController = new AbortController();
const { signal } = abortController;
const ref = useRef();
const startRef = useRef();
startRef.current = state._start;
ref.current = async (signal, params = state) => {
ref.current = async () => {
try {
const params = cloneDeep(state);
const requestUrl = `/${pluginId}/explorer/${targetModel}`;
if (isEmpty(params._q)) {
@ -91,34 +94,50 @@ function SelectWrapper({
};
useEffect(() => {
const abortController = new AbortController();
const { signal } = abortController;
ref.current(signal);
ref.current();
return () => {
abortController.abort();
};
}, [ref]);
const onInputChange = inputValue => {
useEffect(() => {
if (state._q !== '') {
ref.current();
}
return () => {
abortController.abort();
};
}, [state._q]);
useEffect(() => {
if (state._start !== 0) {
ref.current();
}
return () => {
abortController.abort();
};
}, [state._start]);
const onInputChange = (inputValue, { action }) => {
if (action === 'input-change') {
setState(prevState => {
if (prevState._q === inputValue) {
return prevState;
}
return { ...prevState, _q: inputValue };
});
ref.current();
}
return inputValue;
};
const onMenuScrollToBottom = () => {
setState(prevState => ({ ...prevState, _start: prevState._start + 1 }));
ref.current();
};
const isSingle = [
'oneWay',
'oneToOne',