Skip to content

Commit

Permalink
fix(widget): stop auto-correcting relations on partial matches
Browse files Browse the repository at this point in the history
Only query the `valueField` on initial search
Stop changing the initial `value` to avoid "Are you sure you want to leave this page?" popup on non-edited value.
  • Loading branch information
medfreeman committed Sep 16, 2017
1 parent 919e576 commit 881d9b7
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/components/Widgets/RelationControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@ class RelationControl extends Component {
const { value, field } = this.props;
if (value) {
const collection = field.get('collection');
const searchFields = [...new Set(
[
...field.get('searchFields').toJS(),
field.get('valueField'),
]
)];
const searchFields = [ field.get('valueField') ];
this.props.query(this.controlID, collection, searchFields, value);
}
}
Expand All @@ -51,8 +46,6 @@ class RelationControl extends Component {
this.didInitialSearch = true;
const suggestion = nextProps.queryHits.get(this.controlID);
if (suggestion && suggestion.length === 1) {
const value = this.getSuggestionValue(suggestion[0]);
this.props.onChange(value, { [nextProps.field.get('collection')]: { [value]: suggestion[0].data } });
const displayValue = this.getSuggestionDisplayValue(suggestion[0]);
this.setState({ displayValue });
}
Expand Down

0 comments on commit 881d9b7

Please sign in to comment.