Skip to content

Commit

Permalink
fixed displaying defaultData instead of empty data (formio#4670)
Browse files Browse the repository at this point in the history
Co-authored-by: Hanna Kurban <[email protected]>
  • Loading branch information
HannaKurban and Hanna Kurban authored Apr 6, 2022
1 parent 7e63fc8 commit d730559
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/select/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ export default class SelectComponent extends Field {
noUpdateEvent: true
});
}
else if (this.shouldAddDefaultValue) {
else if (this.shouldAddDefaultValue && !this.options.readOnly) {
// If a default value is provided then select it.
const defaultValue = this.defaultValue;
if (!this.isEmpty(defaultValue)) {
Expand Down Expand Up @@ -564,7 +564,7 @@ export default class SelectComponent extends Field {
options = options || {};

// See if we should load items or not.
if (!this.shouldLoad) {
if (!this.shouldLoad || this.options.readOnly) {
this.isScrollLoading = false;
this.loading = false;
this.itemsLoadedResolve();
Expand Down Expand Up @@ -1298,7 +1298,7 @@ export default class SelectComponent extends Field {
}
const notFoundValuesToAdd = [];
const added = values.reduce((defaultAdded, value) => {
if (!value || _.isEmpty(value)) {
if ((!value || _.isEmpty(value)) && !this.options.readOnly) {
return defaultAdded;
}
let found = false;
Expand Down Expand Up @@ -1561,7 +1561,7 @@ export default class SelectComponent extends Field {
}

setChoicesValue(value, hasPreviousValue, flags = {}) {
const hasValue = !this.isEmpty(value);
const hasValue = !this.isEmpty(value) || flags.fromSubmission;
hasPreviousValue = (hasPreviousValue === undefined) ? true : hasPreviousValue;
if (this.choices) {
// Now set the value.
Expand Down

0 comments on commit d730559

Please sign in to comment.