Skip to content

Commit

Permalink
fix(ui): disableListColumn on first field breaks filter condition sel…
Browse files Browse the repository at this point in the history
…ection (#10267)

What?
This PR fixes an issue with the WhereBuilder where if the first field in
a collection had disableListFilter enabled, the select in that fields
Condition would be rendered disabled, making it impossible to query docs
in list view.

Why?
To allow users to query their documents while still being able to set
disableListFilter on fields regardless of where they are in the
collection hierarchy.

How?
By setting the intitial field selection to the first
`admin.listDisabledColumn: false` field when clicking the Add Condition
button in the WhereBuilder and Condition components.

Fixes #10110
  • Loading branch information
DanRibbens authored Dec 30, 2024
1 parent 16c6abe commit 039b489
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/ui/src/elements/WhereBuilder/Condition/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export const Condition: React.FC<Props> = (props) => {
onClick={() =>
addCondition({
andIndex: andIndex + 1,
fieldName: fields[0].value,
fieldName: fields.find((field) => !field.field.admin?.disableListFilter).value,
orIndex,
relation: 'and',
})
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/src/elements/WhereBuilder/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ export const WhereBuilder: React.FC<WhereBuilderProps> = (props) => {
if (reducedFields.length > 0) {
addCondition({
andIndex: 0,
fieldName: reducedFields[0].value,
fieldName: reducedFields.find((field) => !field.field.admin?.disableListFilter)
.value,
orIndex: conditions.length,
relation: 'or',
})
Expand Down

0 comments on commit 039b489

Please sign in to comment.