refine validation

pull/5370/head
LianaHus 4 years ago committed by Liana Husikyan
parent 19e71a1bfc
commit 21f8544eea
  1. 1
      apps/remix-ide-e2e/src/tests/runAndDeploy.ts
  2. 9
      apps/remix-ide/src/app/tabs/runTab/settings.js
  3. 626
      package-lock.json

@ -28,6 +28,7 @@ module.exports = {
.assert.containsText('*[data-id="sidePanelSwapitTitle"]', 'DEPLOY & RUN TRANSACTIONS') .assert.containsText('*[data-id="sidePanelSwapitTitle"]', 'DEPLOY & RUN TRANSACTIONS')
.clearValue('#value') .clearValue('#value')
.setValue('#value', '0000') .setValue('#value', '0000')
.click('*[data-id="remixDRValueLabel"]')
.assert.containsText('*[data-id="dandrValue"]', '0') .assert.containsText('*[data-id="dandrValue"]', '0')
.clearValue('#value') .clearValue('#value')
.setValue('#value', '-44') .setValue('#value', '-44')

@ -54,7 +54,10 @@ class SettingsUI {
} }
validateInputKey (e) { validateInputKey (e) {
if (!helper.isNumeric(e.key) || (e.key === 0 && !this.el.querySelector('#value').value)) { // preventing not numeric keys
// preventing 000 case
if (!helper.isNumeric(e.key) ||
(e.key === '0' && !parseInt(this.el.querySelector('#value').value) && this.el.querySelector('#value').value.length > 0)) {
e.preventDefault() e.preventDefault()
e.stopImmediatePropagation() e.stopImmediatePropagation()
} }
@ -66,7 +69,7 @@ class SettingsUI {
// assign 0 if given value is // assign 0 if given value is
// - empty // - empty
// - not valid (for ex 4345-54) // - not valid (for ex 4345-54)
// - contains only '0's (for ex 0000) // - contains only '0's (for ex 0000) copy past or edit
if (!valueEl.value) valueEl.value = 0 if (!valueEl.value) valueEl.value = 0
// if giveen value is negative(possible with copy-pasting) set to 0 // if giveen value is negative(possible with copy-pasting) set to 0
if (valueEl.value < 0) valueEl.value = 0 if (valueEl.value < 0) valueEl.value = 0
@ -134,7 +137,7 @@ class SettingsUI {
const valueEl = yo` const valueEl = yo`
<div class="${css.crow}"> <div class="${css.crow}">
<label class="${css.settingsLabel}">Value</label> <label class="${css.settingsLabel}" data-id="remixDRValueLabel">Value</label>
<div class="${css.gasValueContainer}"> <div class="${css.gasValueContainer}">
<input <input
type="number" type="number"

626
package-lock.json generated

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save