Skip to content

Commit 3dca8f1

Browse files
jyash97metagrover
authored andcommitted
web: add nestedField support in DatePicker (#718)
1 parent 97cef51 commit 3dca8f1

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

packages/web/src/components/date/DatePicker.js

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ class DatePicker extends Component {
5151
this.updateQuery(
5252
this.state.currentDate ? this.formatInputDate(this.state.currentDate) : null,
5353
nextProps,
54-
));
54+
),
55+
);
5556
if (!isEqual(this.props.defaultSelected, nextProps.defaultSelected)) {
5657
this.handleDateChange(nextProps.defaultSelected, true, nextProps);
5758
} else if (
@@ -86,6 +87,17 @@ class DatePicker extends Component {
8687
},
8788
};
8889
}
90+
91+
if (query && props.nestedField) {
92+
return {
93+
query: {
94+
nested: {
95+
path: props.nestedField,
96+
query,
97+
},
98+
},
99+
};
100+
}
89101
return query;
90102
};
91103

@@ -191,8 +203,9 @@ class DatePicker extends Component {
191203
}}
192204
{...this.props.dayPickerInputProps}
193205
/>
194-
{this.props.showClear
195-
&& this.state.currentDate && <CancelSvg onClick={this.clearDayPicker} />}
206+
{this.props.showClear && this.state.currentDate && (
207+
<CancelSvg onClick={this.clearDayPicker} />
208+
)}
196209
</Flex>
197210
</DateContainer>
198211
);
@@ -217,6 +230,7 @@ DatePicker.propTypes = {
217230
focused: types.bool,
218231
initialMonth: types.dateObject,
219232
innerClass: types.style,
233+
nestedField: types.string,
220234
numberOfMonths: types.number,
221235
onQueryChange: types.func,
222236
placeholder: types.string,

0 commit comments

Comments
 (0)