Skip to content

Commit dba0f8a

Browse files
committed
Added more documentation
1 parent b59b5ba commit dba0f8a

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/SearchInput/SearchInput.Component.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ export class SearchInputComponent extends Component {
130130
onSearch={this.performSearch}
131131
/>`;
132132

133+
exampleAutoCompleteMethod = `performAutoComplete = searchTerm => {
134+
const searchResults = this.data.filter(item => {
135+
return item.toLowerCase().startsWith(searchTerm.toLowerCase());
136+
});
137+
138+
this.setState({ data: searchResults });
139+
};`;
140+
133141
performAutoComplete = searchTerm => {
134142
const searchResults = this.data.filter(item => {
135143
return item.toLowerCase().startsWith(searchTerm.toLowerCase());
@@ -201,7 +209,14 @@ export class SearchInputComponent extends Component {
201209
A text input with Search button that includes auto-complete
202210
functionality. Clicking on the Search button, selecting an
203211
auto-complete item or pressing the Enter key will execute the onSearch
204-
method.
212+
method. <br />
213+
<br />
214+
For the auto-complete functionality to work the parent component needs
215+
to pass a method to the <b>onAutoComplete</b> property. The Search
216+
Input component will pass to the onAutoComplete method the value
217+
entered in to the search box. It is up to the parent component to
218+
create the array of values to display and set it to the <b>data</b>{' '}
219+
property of the Search Input component.
205220
</Description>
206221
<DocsTile>
207222
<div>
@@ -214,6 +229,12 @@ export class SearchInputComponent extends Component {
214229
</div>
215230
</DocsTile>
216231
<DocsText>{this.autoCompleteSearchInputCode}</DocsText>
232+
<Separator />
233+
<Description>
234+
Sample auto-complete method which filters an array of fruit based on
235+
the search input value.
236+
</Description>
237+
<DocsText>{this.exampleAutoCompleteMethod}</DocsText>
217238

218239
<Separator />
219240
</div>

0 commit comments

Comments
 (0)