Skip to content

Commit 6ae111e

Browse files
committed
fix: $helper.field.defaultValue()
1 parent eb9a296 commit 6ae111e

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

panel/src/helpers/field.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ export function defaultValue(field) {
1212
return clone(field.default);
1313
}
1414

15-
const component =
16-
window.panel.app.$options.components[`k-${field.type}-field`];
17-
18-
const valueProp = component?.options.props?.value;
15+
const component = window.panel.app.component(`k-${field.type}-field`);
16+
const valueProp = component?.props?.value;
1917

2018
// if the field has no value prop,
2119
// it will be completely skipped

panel/src/helpers/field.test.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,17 @@ describe.concurrent("$helper.field.form()", () => {
99
// mock the app with the component setup
1010
window.panel = {
1111
app: {
12-
$options: {
13-
components: {
12+
component(name) {
13+
const components = {
1414
"k-custom-field": {
15-
options: {
16-
props: {
17-
value: {
18-
default: "test"
19-
}
15+
props: {
16+
value: {
17+
default: "test"
2018
}
2119
}
2220
}
23-
}
21+
};
22+
return components[name];
2423
}
2524
}
2625
};

0 commit comments

Comments
 (0)