feat: provide isValid parameter in AdvancedQueryFilter onInput hook#1318
Merged
fengelniederhammer merged 8 commits intoJul 15, 2026
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The onInput callback now receives a second boolean argument `isValid` indicating whether the current input is valid or not. This allows surrounding code (e.g. forms) to block submission when the query is invalid. - onInput(undefined, true) when input is cleared - onInput(query, true) on successful validation - onInput(query, false) on parse failure, disallowed fields, or network error Callers updated to only apply the new value when isValid is true.
Copilot
AI
changed the title
[WIP] Fix AdvancedQueryFilter to provide validity information in onInput hook
feat: provide isValid parameter in AdvancedQueryFilter onInput hook
Jul 8, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the AdvancedQueryFilter hook contract so callers can react to invalid input by receiving an isValid boolean with every onInput callback, enabling features like disabling form submission when the query is invalid (resolves #1217).
Changes:
- Updated
AdvancedQueryFilter.onInputsignature to(newValue, isValid)and made it fire for invalid/error outcomes as well as valid ones. - Updated existing selectors (
BaselineSelector,VariantSelector) to preserve prior behavior by only propagating values whenisValid === true. - Added validity plumbing for collection variants:
VariantEditorreports validity toCollectionForm, which disables submit while any advanced-query variant is invalid; browser tests added/updated accordingly.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| website/src/components/pageStateSelectors/VariantSelector.tsx | Only applies advanced query changes when the validated input is valid. |
| website/src/components/pageStateSelectors/BaselineSelector.tsx | Only applies advanced query changes when the validated input is valid. |
| website/src/components/genspectrum/AdvancedQueryFilter.tsx | Changes onInput signature and emits validity for success/error/cleared states. |
| website/src/components/genspectrum/AdvancedQueryFilter.browser.spec.tsx | Updates expectations to include (value, isValid) and asserts calls on invalid cases. |
| website/src/components/collections/form/VariantEditor.tsx | Adds onValidityChange reporting and treats empty advanced query as invalid for variants. |
| website/src/components/collections/form/VariantEditor.browser.spec.tsx | Adds coverage for invalid reporting + initial empty query behavior. |
| website/src/components/collections/form/CollectionForm.tsx | Tracks invalid variants and disables submit when any variant is invalid. |
| website/src/components/collections/form/CollectionForm.browser.spec.tsx | Verifies submit enable/disable behavior for invalid/empty advanced query variants. |
Comments suppressed due to low confidence (1)
website/src/components/genspectrum/AdvancedQueryFilter.tsx:97
- Update/clear the latest-query ref when scheduling validation and when the input is cleared, otherwise the stale-result guard can’t work reliably.
if (inputValue === undefined || inputValue === '') {
setValidationState({ type: 'idle' });
onInput?.(undefined, true);
return;
}
setValidationState({ type: 'validating' });
const timeout = setTimeout(() => validateQuery(inputValue), DEBOUNCE_MS);
fhennig
requested changes
Jul 13, 2026
fhennig
approved these changes
Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
resolves #1217
Summary
Two related changes:
1.
AdvancedQueryFilter.onInputnow reports validity. Previously it only fired on valid input, giving callers no way to know when the current value is invalid (e.g. to disable a form submit button). The hook now always fires after validation completes, with anisValidboolean as the second argument.New signature:
Behavior by state:
onInput(undefined, true)onInput(query, true)(unchanged)onInput(query, false)(previously not called)Existing callers (
BaselineSelector,VariantSelector) updated to only propagate the value to state whenisValidistrue, preserving prior behavior.2. Collection form: disable submit while an advanced query is invalid. In the collection create/edit form, a variant defined via advanced query now blocks submitting while its query is invalid. An empty advanced query is also treated as invalid (it is not a usable variant definition).
VariantEditorreports each variant's validity up toCollectionForm, which disables the submit button while any variant is invalid.Screenshot
N/A — the only visual change is the submit button becoming disabled while an advanced query variant is invalid/empty.
PR Checklist