Skip to content

Commit

Permalink
fix(ui): safely accesses field in default filter component (#9276)
Browse files Browse the repository at this point in the history
### 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
  • Loading branch information
akhrarovsaid authored Nov 18, 2024
1 parent a25ddc5 commit 1a31e63
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const DefaultFilter: React.FC<Props> = ({
return (
<Text
disabled={disabled}
field={internalField.field as TextFieldClient}
field={internalField?.field as TextFieldClient}
onChange={onChange}
operator={operator}
value={value}
Expand Down

0 comments on commit 1a31e63

Please sign in to comment.