Bug 1213412 - don't override property while editing. r=bgrins

This commit is contained in:
Tom Tromey 2015-10-27 12:22:00 +01:00
parent 1189d2abd3
commit 90ce2b7ece
3 changed files with 15 additions and 7 deletions

View File

@ -1089,9 +1089,11 @@ SwatchBasedEditorTooltip.prototype = {
*/
revert: function() {
if (this.activeSwatch) {
let swatch = this.swatches.get(this.activeSwatch);
swatch.callbacks.onRevert();
this._reverted = true;
let swatch = this.swatches.get(this.activeSwatch);
this.tooltip.once("hiding", () => {
swatch.callbacks.onRevert();
});
}
},

View File

@ -3418,8 +3418,9 @@ TextPropertyEditor.prototype = {
!this.isValid() ||
!this.prop.overridden;
if (this.prop.overridden || !this.prop.enabled ||
!this.prop.isKnownProperty()) {
if (!this.editing &&
(this.prop.overridden || !this.prop.enabled ||
!this.prop.isKnownProperty())) {
this.element.classList.add("ruleview-overridden");
} else {
this.element.classList.remove("ruleview-overridden");
@ -3804,7 +3805,7 @@ TextPropertyEditor.prototype = {
* value of this property before editing.
*/
_onSwatchRevert: function() {
this._previewValue(this.prop.value);
this._previewValue(this.prop.value, true);
this.update();
},
@ -3860,11 +3861,13 @@ TextPropertyEditor.prototype = {
*
* @param {String} value
* The value to set the current property to.
* @param {Boolean} reverting
* True if we're reverting the previously previewed value
*/
_previewValue: function(value) {
_previewValue: function(value, reverting = false) {
// Since function call is throttled, we need to make sure we are still
// editing, and any selector modifications have been completed
if (!this.editing || this.ruleEditor.isEditing) {
if (!reverting && (!this.editing || this.ruleEditor.isEditing)) {
return;
}

View File

@ -60,6 +60,9 @@ function* testCreateNew(view) {
is(editor, inplaceEditor(textProp.editor.valueSpan),
"Editing the value span now.");
ok(!textProp.editor.element.classList.contains("ruleview-overridden"),
"property should not be overridden.");
info("Entering a value and bluring the field to expect a rule change");
editor.input.value = "#XYZ";
let onBlur = once(editor.input, "blur");