Skip to content

Commit

Permalink
EuiSearchBox - pass rest to EuiFieldSearch (#514)
Browse files Browse the repository at this point in the history
* add rest to search_box

* pass box props to search_bar

* change log

* use local vars
  • Loading branch information
nreese authored Mar 15, 2018
1 parent d925587 commit 74cd1cd
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# [`master`](https://github.com/elastic/eui/tree/master)

- `EuiInMemoryTable` pass items to BasicTable when message is provided ([#517](https://github.com/elastic/eui/pull/517)).
- `EuiSearchBox` now passes unused props through to `EuiFieldSearch` ([#514](https://github.com/elastic/eui/pull/514))

# [`0.0.27`](https://github.com/elastic/eui/tree/v0.0.27)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,9 @@ exports[`EuiInMemoryTable with pagination, selection, sorting and configured sea
<EuiSearchBar
box={
Object {
"aria-label": "aria-label",
"className": "testClass1 testClass2",
"data-test-subj": "test subject string",
"incremental": true,
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/basic_table/in_memory_table.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,8 @@ describe('EuiInMemoryTable', () => {
search: {
defaultQuery: 'name:name1',
box: {
incremental: true
incremental: true,
...requiredProps
},
filters: [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`SearchBar render - no config, no query 1`] = `
exports[`SearchBar render - box 1`] = `
<EuiFlexGroup
alignItems="center"
component="div"
Expand All @@ -14,17 +14,20 @@ exports[`SearchBar render - no config, no query 1`] = `
grow={true}
>
<EuiSearchBox
aria-label="aria-label"
className="testClass1 testClass2"
data-test-subj="test subject string"
incremental={false}
isInvalid={false}
onSearch={[Function]}
placeholder="Search..."
placeholder="find something..."
query=""
/>
</EuiFlexItem>
</EuiFlexGroup>
`;

exports[`SearchBar render - no query, custom box placeholder and incremental 1`] = `
exports[`SearchBar render - no config, no query 1`] = `
<EuiFlexGroup
alignItems="center"
component="div"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

exports[`EuiSearchBox render - custom placeholder and incremental 1`] = `
<EuiFieldSearch
aria-label="aria-label"
className="testClass1 testClass2"
data-test-subj="test subject string"
defaultValue=""
fullWidth={true}
incremental={true}
Expand All @@ -14,6 +17,9 @@ exports[`EuiSearchBox render - custom placeholder and incremental 1`] = `

exports[`EuiSearchBox render - no config 1`] = `
<EuiFieldSearch
aria-label="aria-label"
className="testClass1 testClass2"
data-test-subj="test subject string"
defaultValue=""
fullWidth={true}
incremental={false}
Expand Down
12 changes: 5 additions & 7 deletions src/components/search_bar/search_bar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,12 @@ describe('SearchBar', () => {
expect(component).toMatchSnapshot();
});

test('render - no query, custom box placeholder and incremental', () => {
test('render - box', () => {
const props = {
...requiredProps,
config: {
box: {
placeholder: 'find something...',
incremental: false
}
box: {
placeholder: 'find something...',
incremental: false,
...requiredProps
},
onChange: () => {}
};
Expand Down
23 changes: 17 additions & 6 deletions src/components/search_bar/search_box.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,27 @@ export class EuiSearchBox extends Component {
}

render() {
const {
placeholder,
query,
incremental,
onSearch,
isInvalid,
title,
...rest
} = this.props;

return (
<EuiFieldSearch
inputRef={input => this.inputElement = input}
fullWidth
placeholder={this.props.placeholder}
defaultValue={this.props.query}
incremental={this.props.incremental}
onSearch={(query) => this.props.onSearch(query)}
isInvalid={this.props.isInvalid}
title={this.props.title}
placeholder={placeholder}
defaultValue={query}
incremental={incremental}
onSearch={(query) => onSearch(query)}
isInvalid={isInvalid}
title={title}
{...rest}
/>
);
}
Expand Down

0 comments on commit 74cd1cd

Please sign in to comment.