mirror of
https://github.com/google/blockly.git
synced 2026-01-10 18:37:09 +01:00
Prevent setting a number value to NaN. Select the field value on entry to an input field. State the contents of the input field when describing the field.
This commit is contained in:
@@ -30,12 +30,12 @@ blocklyApp.FieldComponent = ng.core
|
||||
template: `
|
||||
<input *ngIf="isTextInput()" [id]="mainFieldId" type="text" [disabled]="disabled"
|
||||
[ngModel]="field.getValue()" (ngModelChange)="field.setValue($event)"
|
||||
[attr.aria-label]="disabled ? 'Disabled text field' : 'Press Enter to edit text'"
|
||||
[attr.aria-label]="disabled ? 'Disabled text field' : 'Press Enter to edit text: ' + field.getValue()"
|
||||
tabindex="-1">
|
||||
|
||||
<input *ngIf="isNumberInput()" [id]="mainFieldId" type="number" [disabled]="disabled"
|
||||
[ngModel]="field.getValue()" (ngModelChange)="field.setValue($event)"
|
||||
[attr.aria-label]="disabled ? 'Disabled number field' : 'Press Enter to edit number'"
|
||||
[ngModel]="field.getValue()" (ngModelChange)="setNumberValue($event)"
|
||||
[attr.aria-label]="disabled ? 'Disabled number field' : 'Press Enter to edit number: ' + field.getValue()"
|
||||
tabindex="-1">
|
||||
|
||||
<div *ngIf="isDropdown()">
|
||||
@@ -78,6 +78,10 @@ blocklyApp.FieldComponent = ng.core
|
||||
// this.generateElementNames() are unique.
|
||||
this.idMap = this.utilsService.generateIds(elementsNeedingIds);
|
||||
},
|
||||
setNumberValue: function(newValue) {
|
||||
// Do not permit a residual value of NaN after a backspace event.
|
||||
this.field.setValue(newValue || 0);
|
||||
},
|
||||
generateAriaLabelledByAttr: function(mainLabel, secondLabel) {
|
||||
return mainLabel + ' ' + secondLabel;
|
||||
},
|
||||
|
||||
@@ -454,6 +454,7 @@ blocklyApp.TreeService = ng.core
|
||||
break;
|
||||
} else if (currentNode.tagName == 'INPUT') {
|
||||
currentNode.focus();
|
||||
currentNode.select();
|
||||
this.notificationsService.setStatusMessage(
|
||||
'Type a value, then press Escape to exit');
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user