Fix CSS class for default/non-default schema values not applied to enums, see (#666)

This commit is contained in:
jos 2019-04-02 21:09:17 +02:00
parent ff8be9635a
commit b279ed3069
2 changed files with 17 additions and 10 deletions

View File

@ -8,6 +8,8 @@ https://github.com/josdejong/jsoneditor
- Fixed #416: Clipped action menu for append nodes.
- Improve detection of value type in transform modal.
- Styling improvements in the transform modal.
- Fix CSS class for default/non-default schema values not applied to enums,
see (#666).
## 2018-03-28, version 5.32.1

View File

@ -1921,18 +1921,23 @@ Node.prototype._updateDomDefault = function () {
return;
}
// select either enum dropdown (select) or input value
const inputElement = this.dom.select
? this.dom.select
: this.dom.value;
if (!inputElement) {
return;
}
if (this.value === this.schema.default) {
if (this.dom.select) {
this.dom.value.removeAttribute('title');
} else {
this.dom.value.title = translate('default');
this.dom.value.classList.add('jsoneditor-is-default');
this.dom.value.classList.remove('jsoneditor-is-not-default');
}
inputElement.title = translate('default');
util.addClassName(inputElement, 'jsoneditor-is-default');
util.removeClassName(inputElement, 'jsoneditor-is-not-default');
} else {
this.dom.value.removeAttribute('title');
this.dom.value.classList.remove('jsoneditor-is-default');
this.dom.value.classList.add('jsoneditor-is-not-default');
inputElement.removeAttribute('title');
util.removeClassName(inputElement, 'jsoneditor-is-default');
util.addClassName(inputElement, 'jsoneditor-is-not-default');
}
};