Skip to content

Commit

Permalink
Merge branch 'master' into FIO-8510-nested-forms
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanbond committed Oct 8, 2024
2 parents 2a822ee + a460f7b commit 65f2288
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- FIO-9153-9154: fixed console errors when navigating tagpad validation errors
- FIO-9127 fixed saving an empty value for day component after deleting values
- FIO-9120: Fix issue with unchecking radio default value
- FIO-7195/FIO-8234: Fixes an issue where Select renders value properties instead of labels in DataTable

### New Features

Expand Down
17 changes: 13 additions & 4 deletions src/components/select/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,12 @@ export default class SelectComponent extends ListComponent {
return this.sanitize(value, this.shouldSanitizeValue);
}

if (this.component.multiple && _.isArray(this.dataValue) ? this.dataValue.find((val) => this.normalizeSingleValue(value) === val) : (this.dataValue === this.normalizeSingleValue(value))) {
// Inside DataTable component won't have dataValue set
const shouldUseSelectData = (this.component.multiple && _.isArray(this.dataValue)
? this.dataValue.find((val) => this.normalizeSingleValue(value) === val)
: (this.dataValue === this.normalizeSingleValue(value))) || this.inDataTable;

if (shouldUseSelectData) {
const selectData = this.selectData;
if (selectData) {
const templateValue = this.component.reference && value?._id ? value._id.toString() : value;
Expand Down Expand Up @@ -1461,7 +1466,7 @@ export default class SelectComponent extends ListComponent {
// Check to see if we need to save off the template data into our metadata.
const templateValue = this.component.reference && value?._id ? value._id.toString() : value;
const shouldSaveData = !valueIsObject || this.component.reference;
if (templateValue && shouldSaveData && this.templateData && this.templateData[templateValue] && this.root?.submission) {
if (!_.isNil(templateValue) && shouldSaveData && this.templateData && this.templateData[templateValue] && this.root?.submission) {
const submission = this.root.submission;
if (!submission.metadata) {
submission.metadata = {};
Expand Down Expand Up @@ -1751,8 +1756,12 @@ export default class SelectComponent extends ListComponent {
asString(value, options = {}) {
value = value ?? this.getValue();

if (options.modalPreview) {
const template = this.itemTemplate(value, value);
if (options.modalPreview || this.inDataTable) {
if (this.inDataTable) {
value = this.undoValueTyping(value);
}
const templateValue = (this.isEntireObjectDisplay() && !_.isObject(value.data)) ? { data: value } : value;
const template = this.itemTemplate(templateValue, value, options);
return template;
}
//need to convert values to strings to be able to compare values with available options that are strings
Expand Down

0 comments on commit 65f2288

Please sign in to comment.