Skip to content

Keep query-based dropdown empty after clicking clear - #7798

Open
amirshahzadhashmi7145 wants to merge 1 commit into
getredash:masterfrom
amirshahzadhashmi7145:fix/7361-query-dropdown-clear-keeps-empty
Open

amirshahzadhashmi7145 wants to merge 1 commit into
getredash:masterfrom
amirshahzadhashmi7145:fix/7361-query-dropdown-clear-keeps-empty

Conversation

@amirshahzadhashmi7145

@amirshahzadhashmi7145 amirshahzadhashmi7145 commented Sep 3, 2026

Copy link
Copy Markdown

Summary

Test plan

  • Query-based dropdown: select a value, click X, field stays empty
  • Selecting a value still works
  • After options reload, a valid existing value is kept

Review in cubic

@cubic-dev-ai cubic-dev-ai Bot 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.

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="client/app/components/QueryBasedParameterInput.jsx">

<violation number="1" location="client/app/components/QueryBasedParameterInput.jsx:56">
P2: When a dropdown query contains an option with an empty-string value, this branch clears it before the option lookup, so the option cannot be selected or restored. Treat only nullish values as the clear state, since empty strings are supported option values.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

value = found ? value : get(first(options), "value");
this.setState({ value });
return value;
if (value == null || value === "") {

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.

P2: When a dropdown query contains an option with an empty-string value, this branch clears it before the option lookup, so the option cannot be selected or restored. Treat only nullish values as the clear state, since empty strings are supported option values.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At client/app/components/QueryBasedParameterInput.jsx, line 56:

<comment>When a dropdown query contains an option with an empty-string value, this branch clears it before the option lookup, so the option cannot be selected or restored. Treat only nullish values as the clear state, since empty strings are supported option values.</comment>

<file context>
@@ -53,10 +53,14 @@ export default class QueryBasedParameterInput extends React.Component {
-    value = found ? value : get(first(options), "value");
-    this.setState({ value });
-    return value;
+    if (value == null || value === "") {
+      this.setState({ value: undefined });
+      return null;
</file context>
Suggested change
if (value == null || value === "") {
if (value == null) {

@greptile-apps

greptile-apps Bot commented Sep 3, 2026

Copy link
Copy Markdown

Greptile Summary

The PR preserves an explicitly cleared query-based dropdown instead of automatically selecting its first option again.

  • Adds an early return for null, undefined, and empty-string values.
  • Retains the existing validation and fallback behavior for non-empty selections.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
client/app/components/QueryBasedParameterInput.jsx Adds empty-value handling before the existing option validation and first-option fallback; no eligible follow-up defect was identified.

Reviews (3): Last reviewed commit: "Keep query-based dropdown empty after cl..." | Re-trigger Greptile

@yoshiokatsuneo

Copy link
Copy Markdown
Contributor

I think it is easier to review if the diff for PR is minimum.

@amirshahzadhashmi7145

Copy link
Copy Markdown
Author

Thanks for the feedback — I've reduced the diff to the minimum needed for the fix: a 4-line early return in `setValue` when the value is cleared, with no other logic changes.

Rebased onto latest `master` as well.

@amirshahzadhashmi7145
amirshahzadhashmi7145 force-pushed the fix/7361-query-dropdown-clear-keeps-empty branch from aca81df to 5ccecac Compare September 6, 2026 20:36
Clearing used to fall back to the first option in the UI even though the parameter value was empty.

Co-authored-by: Cursor <cursoragent@cursor.com>
@amirshahzadhashmi7145
amirshahzadhashmi7145 force-pushed the fix/7361-query-dropdown-clear-keeps-empty branch from 5ccecac to 8e57299 Compare September 6, 2026 20:39
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.

Error when using the "X" button in the Query-Based Dropdown List.

2 participants