Procházet zdrojové kódy

User primary search icon if search is not empty

When searching for a replica, migration or endpoint, don't reset the
search icon's color to grey when leaving the search input if the search
input is not empty. Thus, it is much clearer if the list items are
filtered or not.
Sergiu Miclea před 8 roky
rodič
revize
59333a5bd9
1 změnil soubory, kde provedl 12 přidání a 2 odebrání
  1. 12 2
      src/components/molecules/SearchInput/index.jsx

+ 12 - 2
src/components/molecules/SearchInput/index.jsx

@@ -62,6 +62,7 @@ type State = {
   open: boolean,
   open: boolean,
   hover?: boolean,
   hover?: boolean,
   focus?: boolean,
   focus?: boolean,
+  value: string,
 }
 }
 class SearchInput extends React.Component<Props, State> {
 class SearchInput extends React.Component<Props, State> {
   static defaultProps = {
   static defaultProps = {
@@ -76,6 +77,7 @@ class SearchInput extends React.Component<Props, State> {
 
 
     this.state = {
     this.state = {
       open: false,
       open: false,
+      value: '',
     }
     }
 
 
     // $FlowIssue
     // $FlowIssue
@@ -129,13 +131,21 @@ class SearchInput extends React.Component<Props, State> {
         <Input
         <Input
           _ref={input => { this.input = input }}
           _ref={input => { this.input = input }}
           placeholder={this.props.placeholder}
           placeholder={this.props.placeholder}
-          onChange={e => { this.props.onChange(e.target.value) }}
+          onChange={e => {
+            this.setState({ value: e.target.value })
+            this.props.onChange(e.target.value)
+          }}
+          value={this.state.value}
           onFocus={() => { this.handleFocus() }}
           onFocus={() => { this.handleFocus() }}
           onBlur={() => { this.handleBlur() }}
           onBlur={() => { this.handleBlur() }}
           loading={this.props.loading}
           loading={this.props.loading}
         />
         />
         <SearchButtonStyled
         <SearchButtonStyled
-          primary={this.state.open || (this.props.alwaysOpen && (this.state.hover || this.state.focus))}
+          primary={
+            this.state.open ||
+            (this.props.alwaysOpen && (this.state.hover || this.state.focus)) ||
+            (!this.props.alwaysOpen && this.state.value !== '')
+          }
           onClick={() => { this.handleSearchButtonClick() }}
           onClick={() => { this.handleSearchButtonClick() }}
         />
         />
         {this.props.loading ? <StatusIconStyled status="RUNNING" /> : null}
         {this.props.loading ? <StatusIconStyled status="RUNNING" /> : null}