mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Better <CompositeField> prop defaults
The props.tag default was set directly on props, but the component used it from props.data.tag, hence the default was ineffective. Since empty arrays for props.data override nested React defaults, there's no built-in way to enforce this default. Hardcoding a default felt viable here, since the component allows overrides via props.
This commit is contained in:
parent
5415afe8bf
commit
5d9c8a8b95
@ -12,7 +12,7 @@ class CompositeField extends SilverStripeComponent {
|
||||
|
||||
render() {
|
||||
const legend = this.getLegend();
|
||||
const Tag = this.props.data.tag;
|
||||
const Tag = this.props.data.tag || 'div';
|
||||
|
||||
return (
|
||||
<Tag className={this.props.extraClass}>
|
||||
@ -24,13 +24,11 @@ class CompositeField extends SilverStripeComponent {
|
||||
}
|
||||
|
||||
CompositeField.propTypes = {
|
||||
tag: React.PropTypes.string,
|
||||
legend: React.PropTypes.string,
|
||||
data: React.PropTypes.shape({
|
||||
tag: React.PropTypes.string,
|
||||
legend: React.PropTypes.string,
|
||||
}),
|
||||
extraClass: React.PropTypes.string,
|
||||
};
|
||||
|
||||
CompositeField.defaultProps = {
|
||||
tag: 'div',
|
||||
};
|
||||
|
||||
export default CompositeField;
|
||||
|
Loading…
x
Reference in New Issue
Block a user