This is an automated email from the ASF dual-hosted git repository.

hanahmily pushed a commit to branch public/favicon
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking-ui.git

commit c0016743d26999cc1336bf719f45427e41f0e21c
Author: hanahmily <hanahm...@gmail.com>
AuthorDate: Thu Mar 8 13:51:15 2018 +0800

    Add default value to Search component
---
 src/components/Page/Search/index.js | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/components/Page/Search/index.js 
b/src/components/Page/Search/index.js
index 5986b4e..45b9ae0 100644
--- a/src/components/Page/Search/index.js
+++ b/src/components/Page/Search/index.js
@@ -27,14 +27,18 @@ export default class Search extends PureComponent {
   constructor(props) {
     super(props);
     this.lastFetchId = 0;
+    this.originFetchServer = this.fetchServer;
     this.fetchServer = debounce(this.fetchServer, 800);
   }
   state = {
     data: [],
     fetching: false,
   }
-  fetchServer = (value) => {
-    if (!value || value.length < 1) {
+  componentDidMount() {
+    this.originFetchServer('', true);
+  }
+  fetchServer = (value, isSelectOne) => {
+    if (value === undefined) {
       return;
     }
     const { url, query, variables = {}, transform } = this.props;
@@ -57,6 +61,9 @@ export default class Search extends PureComponent {
         }
         const list = body.data[Object.keys(body.data)[0]];
         this.setState({ data: (transform ? list.map(transform) : list), 
fetching: false });
+        if (isSelectOne && this.state.data.length > 0) {
+          this.handleSelect(this.state.data[0]);
+        }
       });
   }
   handleSelect = (value) => {

-- 
To stop receiving notification emails like this one, please contact
hanahm...@apache.org.

Reply via email to