Skip to content
Browse files

use accessor options rather than prop options

  • Loading branch information...
1 parent 501011e commit af0711b077a4bd86a4ca701901192b6cd8ddb5d5 @ssetem ssetem committed
View
4 CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.8.3 (17th March, 2016)
+### Bug Fixes
+ - SortingSelector handles for app reload.
+
## 0.8.2 (17th March, 2016)
### Bug Fixes
- PageSizeSelector synchronises state correctly with url
View
4 docs/setup/project-setup.md
@@ -45,8 +45,8 @@ Requires React, ReactDOM to be included before searchkit. Within the release fol
```html
<script type="text/javascript" src="//cdn.jsdelivr.net/react/0.14.7/react.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/react/0.14.7/react-dom.min.js"></script>
- <script type="text/javascript" src="//cdn.jsdelivr.net/searchkit/0.8.2/bundle.js"></script>
- <link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/searchkit/0.8.2/theme.css">
+ <script type="text/javascript" src="//cdn.jsdelivr.net/searchkit/0.8.3/bundle.js"></script>
+ <link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/searchkit/0.8.3/theme.css">
```
### Use
View
3 src/components/search/sorting-selector/src/SortingSelector.tsx
@@ -57,7 +57,8 @@ export class SortingSelector extends SearchkitComponent<SortingProps, any> {
}
render() {
- const { listComponent, options } = this.props
+ const { listComponent } = this.props
+ const options = this.accessor.options.options
const selected = [this.accessor.getSelectedOption().key]
const disabled = !this.hasHits()
View
21 src/components/search/sorting-selector/test/SortSelectorSpec.tsx
@@ -103,6 +103,24 @@ describe("SortingSelector tests", () => {
expect(this.searchkit.performSearch).toHaveBeenCalled()
})
+ it("handle prop reload without breaking computed keys", ()=> {
+ this.wrapper.setProps({options:[
+ {label:"Relevance"},
+ {label:"Latest Releases", field:"released", order:"desc"},
+ {label:"Earliest Releases", field:"released", order:"asc", key:"earliest"}
+ ]})
+ this.setResults()
+ expect(this.wrapper.html()).toEqual(jsxToHTML(
+ <div className="sk-select">
+ <select defaultValue="none">
+ <option value="none">Relevance translated</option>
+ <option value="released_desc">Latest Releases</option>
+ <option value="earliest">Earliest Releases</option>
+ </select>
+ </div>
+ ))
+ })
+
it("custom mod, className, listComponent", ()=> {
this.wrapper = mount(
<SortingSelector searchkit={this.searchkit}
@@ -111,7 +129,7 @@ describe("SortingSelector tests", () => {
{label:"Latest Releases", field:"released", order:"desc"},
{label:"Earliest Releases", field:"released", order:"asc", key:"earliest"}
]}/>
- )
+ )
expect(this.wrapper.html()).toEqual(jsxToHTML(
<div data-qa="options" className="my-select custom-class is-disabled">
<div className="my-select-option my-select__item is-active" data-qa="option" data-key="none">
@@ -125,6 +143,7 @@ describe("SortingSelector tests", () => {
</div>
</div>
))
+
})
})

0 comments on commit af0711b

Please sign in to comment.
Something went wrong with that request. Please try again.