bug fix: sapi search form: term from autocomplete was not cleaned when typed was changing in field
This commit is contained in:
		@@ -31,7 +31,7 @@ class MaterioSapiSearchForm extends FormBase {
 | 
			
		||||
      '#attributes' => [
 | 
			
		||||
        "placeholder" => $this->t('Search'),
 | 
			
		||||
        // "@keyup" => "keyup",
 | 
			
		||||
        "@keyup.enter" => "submit",
 | 
			
		||||
        // "@keyup.enter" => "submit",
 | 
			
		||||
        "v-model" => "typed",
 | 
			
		||||
        "v-focus" => "",
 | 
			
		||||
        // "v-on:select" => "typed",
 | 
			
		||||
 
 | 
			
		||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -25,7 +25,7 @@ export default {
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
    submit() {
 | 
			
		||||
      console.log("search clicked", this.typed, this.autocomplete);
 | 
			
		||||
      console.log("search submited", this.typed, this.autocomplete);
 | 
			
		||||
      // New search is triggered by Base.vue with router (which will also fill the store)
 | 
			
		||||
      this.$router.push({name:'base', query:{keys:this.typed,term:this.autocomplete}})
 | 
			
		||||
      // this.$router.push({
 | 
			
		||||
@@ -35,9 +35,16 @@ export default {
 | 
			
		||||
    },
 | 
			
		||||
    onAutoCompleteSelect(event, ui){
 | 
			
		||||
      event.preventDefault();
 | 
			
		||||
      // console.log('autoCompleteSelect', event, ui);
 | 
			
		||||
      console.log('autoCompleteSelect', event, ui);
 | 
			
		||||
      this.typed = ui.item.label
 | 
			
		||||
      this.autocomplete = ui.item.value
 | 
			
		||||
      setTimeout(function(){
 | 
			
		||||
        console.log('update autocomplete value after settimeout');
 | 
			
		||||
        this.autocomplete = ui.item.value
 | 
			
		||||
        if(this.typed !== this.keys && this.autocomplete !== this.term){
 | 
			
		||||
          this.submit()
 | 
			
		||||
        }
 | 
			
		||||
      }.bind(this), 1)
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  directives: {
 | 
			
		||||
@@ -60,12 +67,17 @@ export default {
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
  watch: {
 | 
			
		||||
    typed(n, o){
 | 
			
		||||
      console.log('typed changed', o, n);
 | 
			
		||||
      // is changed also when autocomplete change it ...
 | 
			
		||||
      this.autocomplete = null
 | 
			
		||||
    },
 | 
			
		||||
    keys(n, o){
 | 
			
		||||
      console.log('keys changed', n, o);
 | 
			
		||||
      console.log('keys changed', o, n);
 | 
			
		||||
      this.typed = n
 | 
			
		||||
    },
 | 
			
		||||
    term(n, o){
 | 
			
		||||
      console.log('autocomplete changed', n, o);
 | 
			
		||||
      console.log('autocomplete changed', o, n);
 | 
			
		||||
      this.autocomplete = n
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user