Skip to content

Commit

Permalink
Use core's getComponentKey fn in getComponentPath
Browse files Browse the repository at this point in the history
There was a mismatch between how core and formio.js were calculating component path for checkbox components with an input type of radio. This establishes consistency between core and formio.js.
  • Loading branch information
blakekrammes committed Sep 27, 2024
1 parent 33c6b5c commit d157fb9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/Components.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Component from './_classes/component/Component';
import EditFormUtils from './_classes/component/editForm/utils';
import BaseEditForm from './_classes/component/Component.form';
import { getComponentKey } from '../utils/utils';
import _ from 'lodash';
export default class Components {
static _editFormUtils = EditFormUtils;
Expand Down Expand Up @@ -63,7 +64,8 @@ export default class Components {
*/
static getComponentPath(component) {
let path = '';
if (component.component.key) {
const componentKey = getComponentKey(component.component);
if (componentKey) {
let thisPath = component.options?.parent || component;
while (thisPath && !thisPath.allowData && thisPath.parent) {
thisPath = thisPath.parent;
Expand All @@ -75,7 +77,7 @@ export default class Components {
const rowIndex = component.row;
const rowIndexPath = rowIndex && !['container'].includes(thisPath.component.type) ? `[${Number.parseInt(rowIndex)}]` : '';
path = `${thisPath.path}${rowIndexPath}.`;
path += component.component.key;
path += componentKey;
return _.trim(path, '.');
}
return path;
Expand Down

0 comments on commit d157fb9

Please sign in to comment.