Skip to content

[dataquery] Clear operator when the filter field changes - #11031

Open
HenriRabalais wants to merge 1 commit into
aces:29.0-releasefrom
HenriRabalais:2026-07-27_dataquery-clear-criteria-on-field-change
Open

[dataquery] Clear operator when the filter field changes#11031
HenriRabalais wants to merge 1 commit into
aces:29.0-releasefrom
HenriRabalais:2026-07-27_dataquery-clear-criteria-on-field-change

Conversation

@HenriRabalais

Copy link
Copy Markdown
Collaborator

Description

When you change the field on a filter, the Criteria operator dropdown keeps showing the operator you picked for the previous field. You can end up with an operator that is not valid for the new field, or have to re-click the same option when it is still valid.

FilterableSelectGroup wraps react-select without passing a value prop, so react-select keeps the selected option in its own internal state. The field onChange already calls setOp(null) and setValue(''), which clears the parent state, but the dropdown itself never remounts so it keeps displaying the old operator.

The field dropdown right above it already handles this by keying on the category. This does the same thing for the operator dropdown, keying it on the field name so it remounts when the field changes.

Changes

  • Added key={fieldname} to the operator FilterableSelectGroup in the Add criteria modal, so it resets to the "Select an operator" placeholder whenever the field changes.

Testing Instructions

  1. Go to the Data Query Tool (Beta) and click Add Filters, then Add Condition.
  2. Select the "Candidate Demographics" category and the "Date of Birth" field.
  3. Under Criteria, select the < operator. A date input appears next to it.
  4. Now change the field to "Candidate's biological sex".
  5. The operator should reset to "Select an operator" and the date input should disappear. Before this change the dropdown still showed <, which is not a valid operator for an enum field.

Related Issues

Resolves #10781

@github-actions github-actions Bot added the Module: dataquery PR or issue related to (new) dataquery module label Jul 27, 2026
@HenriRabalais HenriRabalais added the 29.0.0 - Bugs Issues found during the release testing for 29.0.0 label Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

29.0.0 - Bugs Issues found during the release testing for 29.0.0 Module: dataquery PR or issue related to (new) dataquery module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant