fix!: Only fire intermediate events when editing input with invalid text. (#8054)

* fix: Fire intermediate events only when editing text input.

* Prefix unused arg with underscore.

* Fix tests.
This commit is contained in:
John Nesky
2024-05-02 18:57:57 -07:00
committed by GitHub
parent 185c82a991
commit 171befa746
6 changed files with 42 additions and 13 deletions

View File

@@ -138,6 +138,7 @@ suite('Angle Fields', function () {
suite('Validators', function () {
setup(function () {
this.field = new Blockly.FieldAngle(1);
this.field.valueWhenEditorWasOpened_ = this.field.getValue();
this.field.htmlInput_ = document.createElement('input');
this.field.htmlInput_.setAttribute('data-old-value', '1');
this.field.htmlInput_.setAttribute('data-untyped-default-value', '1');
@@ -153,7 +154,7 @@ suite('Angle Fields', function () {
return null;
},
value: 2,
expectedValue: '1',
expectedValue: 1,
},
{
title: 'Force Mult of 30 Validator',

View File

@@ -261,6 +261,7 @@ suite('Number Fields', function () {
suite('Validators', function () {
setup(function () {
this.field = new Blockly.FieldNumber(1);
this.field.valueWhenEditorWasOpened_ = this.field.getValue();
this.field.htmlInput_ = document.createElement('input');
this.field.htmlInput_.setAttribute('data-old-value', '1');
this.field.htmlInput_.setAttribute('data-untyped-default-value', '1');
@@ -276,7 +277,7 @@ suite('Number Fields', function () {
return null;
},
value: 2,
expectedValue: '1',
expectedValue: 1,
},
{
title: 'Force End with 6 Validator',

View File

@@ -129,6 +129,7 @@ suite('Text Input Fields', function () {
suite('Validators', function () {
setup(function () {
this.field = new Blockly.FieldTextInput('value');
this.field.valueWhenEditorWasOpened_ = this.field.getValue();
this.field.htmlInput_ = document.createElement('input');
this.field.htmlInput_.setAttribute('data-old-value', 'value');
this.field.htmlInput_.setAttribute('data-untyped-default-value', 'value');