You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "gabotorresruiz (via GitHub)" <gi...@apache.org> on 2025/10/22 17:04:50 UTC
[PR] fix(explore): prevent filter dropdown from closing immediately when clicked [superset]
gabotorresruiz opened a new pull request, #35801:
URL: https://github.com/apache/superset/pull/35801
<!---
Please write the PR title following the conventions at https://www.conventionalcommits.org/en/v1.0.0/
Example:
fix(dashboard): load charts correctly
-->
### SUMMARY
<!--- Describe the change below, including rationale and design decisions -->
Fixes a bug where clicking on the column or operator dropdown in the adhoc filter editor would cause it to open and immediately close, making it impossible to change the selected value.
**Root Cause:**
The bug was caused by a ref callback that ran on every render:
```typescript
ref={ref => {
if (ref && shouldFocusComparator) {
ref.focus(); // Runs on EVERY render, stealing focus!
}
}}
```
When `shouldFocusComparator` was true (both column and operator selected), the callback would continuously call `focus()` on every render, stealing focus from any opened dropdowns and causing them to close immediately.
### BEFORE/AFTER ANIMATED GIF
<!--- Skip this if not applicable -->
#### Before

#### After

### TESTING INSTRUCTIONS
<!--- Required! What steps can be taken to manually verify the changes? -->
1. Navigate to Charts → Open any chart in Explore view
2. In the Filters section, click + Add to add a new adhoc filter
3. Select any column from the dropdown
4. Select any operator from the dropdown (e.g., "Equal to (=)")
5. Test the fix: Click on the operator dropdown again. The Dropdown should remain open and allow you to select a different operator
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] Has associated issue:
- [ ] Required feature flags:
- [x] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): prevent filter dropdown from closing immediately when clicked [superset]
Posted by "korbit-ai[bot] (via GitHub)" <gi...@apache.org>.
korbit-ai[bot] commented on code in PR #35801:
URL: https://github.com/apache/superset/pull/35801#discussion_r2452758260
##########
superset-frontend/src/explore/components/controls/FilterControl/AdhocFilterEditPopoverSimpleTabContent/index.tsx:
##########
@@ -411,16 +413,22 @@ const AdhocFilterEditPopoverSimpleTabContent: FC<Props> = props => {
});
}
};
+
if (!datePicker) {
refreshComparatorSuggestions();
}
- }, [props.adhocFilter.subject]);
+ }, [
+ props.adhocFilter.subject,
+ props.adhocFilter.clause,
+ props.datasource,
+ datePicker,
+ ]);
useEffect(() => {
if (isFeatureEnabled(FeatureFlag.EnableAdvancedDataTypes)) {
fetchSubjectAdvancedDataType(props);
}
- }, [props.adhocFilter.subject]);
+ }, [props.adhocFilter.subject, fetchSubjectAdvancedDataType, props]);
Review Comment:
### Overly broad useEffect dependencies causing unnecessary re-renders <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
The useEffect dependency array includes the entire `props` object, which will cause the effect to run on every render when any prop changes, not just when the relevant properties change.
###### Why this matters
This creates unnecessary re-renders and API calls to fetchSubjectAdvancedDataType, potentially causing performance issues and race conditions. The effect should only run when specific properties that affect the advanced data type fetching actually change.
###### Suggested change ∙ *Feature Preview*
Replace the broad `props` dependency with specific properties that actually affect the advanced data type fetching:
```typescript
useEffect(() => {
if (isFeatureEnabled(FeatureFlag.EnableAdvancedDataTypes)) {
fetchSubjectAdvancedDataType(props);
}
}, [props.adhocFilter.subject, props.datasource, fetchSubjectAdvancedDataType]);
```
Or if fetchSubjectAdvancedDataType is stable and doesn't need to be in dependencies:
```typescript
useEffect(() => {
if (isFeatureEnabled(FeatureFlag.EnableAdvancedDataTypes)) {
fetchSubjectAdvancedDataType(props);
}
}, [props.adhocFilter.subject, props.datasource]);
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/3b976ac7-69da-4f11-9c88-e31f0a6343d2/upvote) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/3b976ac7-69da-4f11-9c88-e31f0a6343d2?what_not_true=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/3b976ac7-69da-4f11-9c88-e31f0a6343d2?what_out_of_scope=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/3b976ac7-69da-4f11-9c88-e31f0a6343d2?what_not_in_standard=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/3b976ac7-69da-4f11-9c88-e31f0a6343d2)
</details>
<sub>
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:46f5364b-b059-45af-aca0-4ab953a12c13 -->
[](46f5364b-b059-45af-aca0-4ab953a12c13)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): prevent filter dropdown from closing immediately when clicked [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #35801:
URL: https://github.com/apache/superset/pull/35801#issuecomment-3433399829
<details open>
<summary><strong>Interaction Diagram by <a href="https://bito.ai#sequence_diagram">Bito</a></strong></summary>
```mermaid
sequenceDiagram
participant User as User Interface
participant FilterCtrl as AdhocFilterControl<br/>🔄 Updated | ●●○ Medium
participant Popover as AdhocFilterEditPopover
participant SimpleTab as AdhocFilterEditPopoverSimpleTabContent<br/>🔄 Updated | ●●● High
participant Hook as useAdvancedDataTypes<br/>🔄 Updated | ●●○ Medium
participant API as SupersetClient API
participant Input as Input Component<br/>🔄 Updated | ●●○ Medium
Note over SimpleTab: Focus management & test restructuring<br/>improved input handling
User->>FilterCtrl: Create/Edit Filter
FilterCtrl->>Popover: Open filter editor
Popover->>SimpleTab: Render simple tab content
SimpleTab->>Hook: Initialize advanced data types
Hook->>API: Fetch advanced data type info
API-->>Hook: Return data type metadata
SimpleTab->>Input: Focus comparator input (new ref logic)
Input-->>SimpleTab: Handle user input changes
SimpleTab-->>Popover: Update filter state
Popover-->>FilterCtrl: Apply filter changes
```
Critical path: User Interface->AdhocFilterControl->AdhocFilterEditPopover->AdhocFilterEditPopoverSimpleTabContent->Input Component
> **Note:** The changes improve focus management in filter input fields using useRef and useEffect, restructure tests from nested describe blocks to top-level tests, and optimize the useAdvancedDataTypes hook with useCallback. The modifications enhance user experience by ensuring proper input focus behavior while maintaining backward compatibility with existing filter functionality.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(explore): prevent filter dropdown from closing immediately when clicked [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #35801:
URL: https://github.com/apache/superset/pull/35801#issuecomment-3433356517
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] refactor(explore): improve focus management in adhoc filter editor [superset]
Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz merged PR #35801:
URL: https://github.com/apache/superset/pull/35801
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org