From 1a31e63b4d424beb509017ab5ed3427f2f089df9 Mon Sep 17 00:00:00 2001 From: Said Akhrarov <36972061+akhrarovsaid@users.noreply.github.com> Date: Mon, 18 Nov 2024 17:52:29 -0500 Subject: [PATCH] fix(ui): safely accesses field in default filter component (#9276) ### What? In the WhereBuilder Condition DefaultFilter component, there is a switch statement that contains components to return based on the built filter in the admin ui. Having a filter built out then navigating to another collection list view causes an error to occur due to InternalField being undefined but the DefaultFilter tries to access the field on it. ### Why? To fix unexpected `cannot access property field of undefined` errors. ### How? Adding a conditional chaining operator. Odd thing here is that the `Text` component where this error originates from doesn't actually make use of the passed `InternalField`. Might be worth it to take a closer look at it. Fixes #9179 --- .../src/elements/WhereBuilder/Condition/DefaultFilter/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui/src/elements/WhereBuilder/Condition/DefaultFilter/index.tsx b/packages/ui/src/elements/WhereBuilder/Condition/DefaultFilter/index.tsx index a1e31b3f7c1..6682ced8dd5 100644 --- a/packages/ui/src/elements/WhereBuilder/Condition/DefaultFilter/index.tsx +++ b/packages/ui/src/elements/WhereBuilder/Condition/DefaultFilter/index.tsx @@ -83,7 +83,7 @@ export const DefaultFilter: React.FC = ({ return (