Skip to content

Commit 039b489

Browse files
authored
fix(ui): disableListColumn on first field breaks filter condition selection (#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
1 parent 16c6abe commit 039b489

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export const Condition: React.FC<Props> = (props) => {
194194
onClick={() =>
195195
addCondition({
196196
andIndex: andIndex + 1,
197-
fieldName: fields[0].value,
197+
fieldName: fields.find((field) => !field.field.admin?.disableListFilter).value,
198198
orIndex,
199199
relation: 'and',
200200
})

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,8 @@ export const WhereBuilder: React.FC<WhereBuilderProps> = (props) => {
233233
if (reducedFields.length > 0) {
234234
addCondition({
235235
andIndex: 0,
236-
fieldName: reducedFields[0].value,
236+
fieldName: reducedFields.find((field) => !field.field.admin?.disableListFilter)
237+
.value,
237238
orIndex: conditions.length,
238239
relation: 'or',
239240
})

0 commit comments

Comments
 (0)