Skip to content

Commit 794b2d3

Browse files
authoredMar 11, 2021
feat(ts): convert connectRefinementList, refinementList (#4658)
* feat(ts): convert connectRefinementList, refinementList - changed how the searchbox templates are done to be easier to type and code - did not migrate RefinementList component - moved prepareTemplateProps tests - fixed a typo in prepareTemplateProps tests * chore: fix lint
1 parent 25d7f51 commit 794b2d3

File tree

14 files changed

+1780
-1511
lines changed

14 files changed

+1780
-1511
lines changed
 

‎src/components/RefinementList/RefinementList.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,18 @@ class RefinementList extends Component {
189189
this.props.searchIsAlwaysActive !== true &&
190190
!(this.props.isFromSearch || !this.props.hasExhaustiveItems);
191191

192+
const templates = this.props.searchBoxTemplateProps
193+
? this.props.searchBoxTemplateProps.templates
194+
: {};
195+
192196
const searchBox = this.props.searchFacetValues && (
193197
<div className={this.props.cssClasses.searchBox}>
194198
<SearchBox
195199
ref={searchBoxRef => (this.searchBox = searchBoxRef)}
196200
placeholder={this.props.searchPlaceholder}
197201
disabled={shouldDisableSearchBox}
198202
cssClasses={this.props.cssClasses.searchable}
199-
templates={this.props.templateProps.templates}
203+
templates={templates}
200204
onChange={event => this.props.searchFacetValues(event.target.value)}
201205
onReset={() => this.props.searchFacetValues('')}
202206
onSubmit={() => this.refineFirstValue()}
@@ -282,6 +286,7 @@ RefinementList.propTypes = {
282286
facetValues: PropTypes.array,
283287
attribute: PropTypes.string,
284288
templateProps: PropTypes.object.isRequired,
289+
searchBoxTemplateProps: PropTypes.object,
285290
toggleRefinement: PropTypes.func.isRequired,
286291
searchFacetValues: PropTypes.func,
287292
searchPlaceholder: PropTypes.string,

‎src/components/RefinementList/__tests__/RefinementList-test.js

+8
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,10 @@ describe('RefinementList', () => {
407407
templates: {
408408
item: item => item.value,
409409
searchableNoResults: x => JSON.stringify(x),
410+
},
411+
},
412+
searchBoxTemplateProps: {
413+
templates: {
410414
reset: 'reset',
411415
submit: 'submit',
412416
loadingIndicator: 'loadingIndicator',
@@ -544,6 +548,10 @@ describe('RefinementList', () => {
544548
templateProps: {
545549
templates: {
546550
item: item => item.value,
551+
},
552+
},
553+
searchBoxTemplateProps: {
554+
templates: {
547555
reset: 'reset',
548556
submit: 'submit',
549557
loadingIndicator: 'loadingIndicator',

0 commit comments

Comments
 (0)
Please sign in to comment.