Skip to content

Commit 1a31e63

Browse files
authored
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
1 parent a25ddc5 commit 1a31e63

File tree

1 file changed

+1
-1
lines changed
  • packages/ui/src/elements/WhereBuilder/Condition/DefaultFilter

1 file changed

+1
-1
lines changed

packages/ui/src/elements/WhereBuilder/Condition/DefaultFilter/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const DefaultFilter: React.FC<Props> = ({
8383
return (
8484
<Text
8585
disabled={disabled}
86-
field={internalField.field as TextFieldClient}
86+
field={internalField?.field as TextFieldClient}
8787
onChange={onChange}
8888
operator={operator}
8989
value={value}

0 commit comments

Comments
 (0)