Skip to content

feat: provide isValid parameter in AdvancedQueryFilter onInput hook#1318

Merged
fengelniederhammer merged 8 commits into
mainfrom
copilot/fix-advanced-query-filter-validity
Jul 15, 2026
Merged

feat: provide isValid parameter in AdvancedQueryFilter onInput hook#1318
fengelniederhammer merged 8 commits into
mainfrom
copilot/fix-advanced-query-filter-validity

Conversation

Copilot AI commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

resolves #1217

Summary

Two related changes:

1. AdvancedQueryFilter.onInput now 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 an isValid boolean as the second argument.

New signature:

onInput?: (newValue: string | undefined, isValid: boolean) => void

Behavior by state:

  • Cleared → onInput(undefined, true)
  • Valid → onInput(query, true) (unchanged)
  • Parse error / disallowed field / network error → onInput(query, false) (previously not called)

Existing callers (BaselineSelector, VariantSelector) updated to only propagate the value to state when isValid is true, 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). VariantEditor reports each variant's validity up to CollectionForm, 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

  • All necessary documentation has been adapted.
  • The implemented feature is covered by an appropriate test.

@vercel

vercel Bot commented Jul 8, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dashboards Ready Ready Preview, Comment Jul 15, 2026 8:47am

Request Review

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
Copilot AI requested a review from fengelniederhammer July 8, 2026 07:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.onInput signature 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 when isValid === true.
  • Added validity plumbing for collection variants: VariantEditor reports validity to CollectionForm, 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);

Comment thread website/src/components/genspectrum/AdvancedQueryFilter.tsx
Comment thread website/src/components/collections/form/CollectionForm.tsx Outdated
Comment thread website/src/components/genspectrum/AdvancedQueryFilter.tsx
Comment thread website/src/components/genspectrum/AdvancedQueryFilter.tsx
Comment thread website/src/components/collections/form/VariantEditor.tsx

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Comment thread website/src/components/collections/form/CollectionForm.tsx
Comment thread website/src/components/genspectrum/AdvancedQueryFilter.tsx
Comment thread website/src/components/genspectrum/AdvancedQueryFilter.tsx
Comment thread website/src/components/collections/form/VariantEditor.tsx
Comment thread website/src/components/collections/form/CollectionForm.tsx

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

@fengelniederhammer fengelniederhammer merged commit 9f05694 into main Jul 15, 2026
12 checks passed
@fengelniederhammer fengelniederhammer deleted the copilot/fix-advanced-query-filter-validity branch July 15, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AdvancedQueryFilter: provide validity information in onInput hook

4 participants