fix ControlHOC ref for redux container widgets
If a widget uses `connect` to receive state updates from the store, `ControlHOC` can no longer get the control instance ref. This fix checks for this case and uses a connect option to obtain the wrapped control ref.
This commit is contained in:
parent
fdeeb44ba3
commit
a4ff229e37
@ -36,8 +36,17 @@ class ControlHOC extends Component {
|
||||
return this.props.value !== nextProps.value;
|
||||
}
|
||||
|
||||
processInnerControlRef = (wrappedControl) => {
|
||||
if (!wrappedControl) return;
|
||||
processInnerControlRef = ref => {
|
||||
if (!ref) return;
|
||||
|
||||
/**
|
||||
* If the widget is a container that receives state updates from the store,
|
||||
* we'll need to get the ref of the actual control via the `react-redux`
|
||||
* `getWrappedInstance` method. Note that connected widgets must pass
|
||||
* `withRef: true` to `connect` in the options object.
|
||||
*/
|
||||
const wrappedControl = ref.getWrappedInstance ? ref.getWrappedInstance() : ref;
|
||||
|
||||
this.wrappedControlValid = wrappedControl.isValid || truthy;
|
||||
|
||||
/**
|
||||
|
@ -128,5 +128,9 @@ export default connect(
|
||||
{
|
||||
query,
|
||||
clearSearch,
|
||||
},
|
||||
null,
|
||||
{
|
||||
withRef: true,
|
||||
}
|
||||
)(RelationControl);
|
||||
|
Loading…
x
Reference in New Issue
Block a user