Skip to content
This repository was archived by the owner on Aug 23, 2022. It is now read-only.

Commit 55bf6a1

Browse files
committed
Merge branch 'lroling8350-define-field-control-props'
2 parents f59ddc1 + 11d6fa5 commit 55bf6a1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/components/field-component.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,16 @@ function getControlType(control, props, options) {
102102

103103
const defaultStrategy = {
104104
Control,
105+
controlPropTypes: fieldPropTypes,
105106
getFieldFromState,
106107
actions,
107108
};
108109

109110
function createFieldClass(customControlPropsMap = {}, s = defaultStrategy) {
111+
// Use the fieldPropTypes if no controlProptypes have been defined to
112+
// maintain backwards compatibiltiy.
113+
const controlPropTypes = s.controlPropTypes || fieldPropTypes;
114+
110115
function mapStateToProps(state, props) {
111116
const {
112117
model,
@@ -161,7 +166,7 @@ function createFieldClass(customControlPropsMap = {}, s = defaultStrategy) {
161166
mapProps = options.controlPropsMap[controlType],
162167
} = props;
163168

164-
const controlProps = pick(props, Object.keys(fieldPropTypes));
169+
const controlProps = pick(props, Object.keys(controlPropTypes));
165170

166171
if (!mapProps) {
167172
return React.cloneElement(
@@ -201,7 +206,7 @@ function createFieldClass(customControlPropsMap = {}, s = defaultStrategy) {
201206
} = this.props;
202207

203208

204-
const allowedProps = omit(this.props, Object.keys(fieldPropTypes));
209+
const allowedProps = omit(this.props, Object.keys(controlPropTypes));
205210
const renderableChildren = typeof children === 'function'
206211
? children(fieldValue)
207212
: children;

0 commit comments

Comments
 (0)