fix(relation): fix relation widget selection bug (#1572)
This commit is contained in:
parent
b2debb05a1
commit
77fbc041bb
@ -41,7 +41,7 @@ export default class Widget extends Component {
|
|||||||
getAsset: PropTypes.func.isRequired,
|
getAsset: PropTypes.func.isRequired,
|
||||||
resolveWidget: PropTypes.func.isRequired,
|
resolveWidget: PropTypes.func.isRequired,
|
||||||
getEditorComponents: PropTypes.func.isRequired,
|
getEditorComponents: PropTypes.func.isRequired,
|
||||||
isFetching: PropTypes.node,
|
isFetching: PropTypes.bool,
|
||||||
query: PropTypes.func.isRequired,
|
query: PropTypes.func.isRequired,
|
||||||
clearSearch: PropTypes.func.isRequired,
|
clearSearch: PropTypes.func.isRequired,
|
||||||
queryHits: PropTypes.oneOfType([
|
queryHits: PropTypes.oneOfType([
|
||||||
|
@ -36,6 +36,7 @@ const entries = (state = defaultState, action) => {
|
|||||||
return state.withMutations((map) => {
|
return state.withMutations((map) => {
|
||||||
const entryIds = List(loadedEntries.map(entry => ({ collection: entry.collection, slug: entry.slug })));
|
const entryIds = List(loadedEntries.map(entry => ({ collection: entry.collection, slug: entry.slug })));
|
||||||
map.set('isFetching', false);
|
map.set('isFetching', false);
|
||||||
|
map.set('fetchID', null);
|
||||||
map.set('page', page);
|
map.set('page', page);
|
||||||
map.set('term', searchTerm);
|
map.set('term', searchTerm);
|
||||||
map.set('entryIds', (!page || isNaN(page) || page === 0) ? entryIds : map.get('entryIds', List()).concat(entryIds));
|
map.set('entryIds', (!page || isNaN(page) || page === 0) ? entryIds : map.get('entryIds', List()).concat(entryIds));
|
||||||
@ -45,6 +46,7 @@ const entries = (state = defaultState, action) => {
|
|||||||
if (action.payload.searchTerm !== state.get('term')) {
|
if (action.payload.searchTerm !== state.get('term')) {
|
||||||
return state.withMutations((map) => {
|
return state.withMutations((map) => {
|
||||||
map.set('isFetching', action.payload.namespace ? true : false);
|
map.set('isFetching', action.payload.namespace ? true : false);
|
||||||
|
map.set('fetchID', action.payload.namespace)
|
||||||
map.set('term', action.payload.searchTerm);
|
map.set('term', action.payload.searchTerm);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -55,6 +57,7 @@ const entries = (state = defaultState, action) => {
|
|||||||
response = action.payload.response;
|
response = action.payload.response;
|
||||||
return state.withMutations((map) => {
|
return state.withMutations((map) => {
|
||||||
map.set('isFetching', false);
|
map.set('isFetching', false);
|
||||||
|
map.set('fetchID', null);
|
||||||
map.set('term', searchTerm);
|
map.set('term', searchTerm);
|
||||||
map.mergeIn(['queryHits'], Map({ [action.payload.namespace]: response.hits }));
|
map.mergeIn(['queryHits'], Map({ [action.payload.namespace]: response.hits }));
|
||||||
});
|
});
|
||||||
|
@ -51,7 +51,8 @@ export default class RelationControl extends React.Component {
|
|||||||
forID: PropTypes.string.isRequired,
|
forID: PropTypes.string.isRequired,
|
||||||
value: PropTypes.node,
|
value: PropTypes.node,
|
||||||
field: PropTypes.node,
|
field: PropTypes.node,
|
||||||
isFetching: PropTypes.node,
|
isFetching: PropTypes.bool,
|
||||||
|
fetchID: PropTypes.string,
|
||||||
query: PropTypes.func.isRequired,
|
query: PropTypes.func.isRequired,
|
||||||
clearSearch: PropTypes.func.isRequired,
|
clearSearch: PropTypes.func.isRequired,
|
||||||
queryHits: PropTypes.oneOfType([
|
queryHits: PropTypes.oneOfType([
|
||||||
@ -141,6 +142,7 @@ export default class RelationControl extends React.Component {
|
|||||||
const {
|
const {
|
||||||
value,
|
value,
|
||||||
isFetching,
|
isFetching,
|
||||||
|
fetchID,
|
||||||
forID,
|
forID,
|
||||||
queryHits,
|
queryHits,
|
||||||
classNameWrapper,
|
classNameWrapper,
|
||||||
@ -172,7 +174,7 @@ export default class RelationControl extends React.Component {
|
|||||||
inputProps={inputProps}
|
inputProps={inputProps}
|
||||||
focusInputOnSuggestionClick={false}
|
focusInputOnSuggestionClick={false}
|
||||||
/>
|
/>
|
||||||
<Loader active={isFetching === this.controlID} />
|
<Loader active={isFetching && this.controlID === fetchID} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user