Skip to content

Commit 2fdfa3a

Browse files
committedFeb 22, 2025
fix proxy in fieldsComponnetsFor
1 parent f1cfd02 commit 2fdfa3a

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed
 

‎packages/base/field-component.gts

+9
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,15 @@ function fieldsComponentsFor<T extends BaseDef>(
420420
}
421421
let field = maybeField;
422422

423+
if (
424+
field.fieldType === 'linksToMany' ||
425+
field.fieldType === 'containsMany'
426+
) {
427+
let stable = stableComponents.get(property);
428+
if (stable) {
429+
return stable;
430+
}
431+
}
423432
let result = field.component(model as unknown as Box<BaseDef>);
424433
stableComponents.set(property, result);
425434
return result;

‎packages/base/links-to-many-component.gts

+1-12
Original file line numberDiff line numberDiff line change
@@ -465,22 +465,11 @@ export function getLinksToManyComponent({
465465
</style>
466466
</template>
467467
};
468-
let stableComponents = new Map<string, BoxComponent[]>();
469468
return new Proxy(linksToManyComponent, {
470469
get(target, property, received) {
471470
// proxying the bare minimum of an Array in order to render within a
472471
// template. add more getters as necessary...
473-
474-
//we need stable components to ensure the modifier remains on the linksToManyComponent and doesn't get recreated
475-
//test would break otherwise but the expected behavior still works in the app (this has to do with the sortable modifier readiness when the component is torn down)
476-
//we previously had a stable component cache in the proxy but removed it since we believe it is not needed
477-
//in order to fix test, I have moved a cache here since this seems like the only place it is affected
478-
//TODO: meet with ed to iron out this cache
479-
let components = stableComponents.get(property);
480-
if (!components) {
481-
components = getComponents();
482-
stableComponents.set(property, components);
483-
}
472+
let components = getComponents();
484473

485474
if (property === Symbol.iterator) {
486475
return components[Symbol.iterator];

0 commit comments

Comments
 (0)
Failed to load comments.