Remove onblur, don't save invalid inputs
This commit is contained in:
		
							parent
							
								
									40f580a0b2
								
							
						
					
					
						commit
						ec16a0c1e0
					
				| 
						 | 
					@ -264,7 +264,6 @@ function configDialog(style) {
 | 
				
			||||||
            va,
 | 
					            va,
 | 
				
			||||||
            type: va.type,
 | 
					            type: va.type,
 | 
				
			||||||
            onfocus: va.type === 'number' ? selectAllOnFocus : null,
 | 
					            onfocus: va.type === 'number' ? selectAllOnFocus : null,
 | 
				
			||||||
            onblur: va.type === 'number' ? updateVarOnBlur : null,
 | 
					 | 
				
			||||||
            onchange: updateVarOnChange,
 | 
					            onchange: updateVarOnChange,
 | 
				
			||||||
            oninput: updateVarOnInput
 | 
					            oninput: updateVarOnInput
 | 
				
			||||||
          };
 | 
					          };
 | 
				
			||||||
| 
						 | 
					@ -317,19 +316,15 @@ function configDialog(style) {
 | 
				
			||||||
      this.va.value = Number(this.value);
 | 
					      this.va.value = Number(this.value);
 | 
				
			||||||
      $('.current-value', this.closest('.config-range')).textContent = this.va.value + (this.va.units || '');
 | 
					      $('.current-value', this.closest('.config-range')).textContent = this.va.value + (this.va.units || '');
 | 
				
			||||||
    } else if (this.type === 'number') {
 | 
					    } else if (this.type === 'number') {
 | 
				
			||||||
      // clamp stored value
 | 
					      const value = Number(this.value);
 | 
				
			||||||
      this.va.value = clampValue(this.value, this.va);
 | 
					      if (clampValue(value, this.va) === value) {
 | 
				
			||||||
 | 
					        this.va.value = value;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      this.va.value = this.type !== 'checkbox' ? this.value : this.checked ? '1' : '0';
 | 
					      this.va.value = this.type !== 'checkbox' ? this.value : this.checked ? '1' : '0';
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // Applied to input[type=number]
 | 
					 | 
				
			||||||
  function updateVarOnBlur() {
 | 
					 | 
				
			||||||
    // clamp value visible to user
 | 
					 | 
				
			||||||
    this.value = this.va.value = clampValue(this.value, this.va);
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  // Clamp input[type=number] to a valid range
 | 
					  // Clamp input[type=number] to a valid range
 | 
				
			||||||
  function clampValue(value, va) {
 | 
					  function clampValue(value, va) {
 | 
				
			||||||
    // Don't restrict to integer values if step is undefined.
 | 
					    // Don't restrict to integer values if step is undefined.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user