Skip to content

Commit dcc73b9

Browse files
committed
Make sure search term is read on initialization
1 parent 8d3af7f commit dcc73b9

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/app-search/URLManager.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ function stateToQueryString(state) {
106106

107107
/**
108108
* The URL Manager is responsible for synchronizing state between
109-
* AppSearchDriver and the URL. There are 3 main cases to handle when
109+
* AppSearchDriver and the URL. There are 2 main cases we handle when
110110
* synchronizing:
111111
*
112112
* 1. When the app loads, AppSearchDriver will need to
@@ -117,8 +117,8 @@ function stateToQueryString(state) {
117117
* AppSearchDriver will need to be notified and given the updated state, so that
118118
* it can re-run the current search. `onURLStateChange` is used for this case.
119119
*
120-
* 3. When state changes in AppSearchDriver, the URL will need to be updated
121-
* to reflect those changes. `onURLStateChange` is used for this case.
120+
* A third case would be handling an update on `history.pushState`, but that
121+
* is outside the scope of this Reference UI for now.
122122
*/
123123

124124
export default class URLManager {

src/containers/SearchBox.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import SearchBox from "../components/SearchBox";
66

77
export class SearchBoxContainer extends Component {
88
static propTypes = {
9+
searchTerm: PropTypes.string.isRequired,
910
setSearchTerm: PropTypes.func.isRequired
1011
};
1112

@@ -14,6 +15,11 @@ export class SearchBoxContainer extends Component {
1415
isFocused: false
1516
};
1617

18+
constructor(props) {
19+
super();
20+
this.state.value = props.searchTerm;
21+
}
22+
1723
handleFocus = e => {
1824
this.setState({
1925
isFocused: true

0 commit comments

Comments
 (0)