msyavuz opened a new pull request, #43405:
URL: https://github.com/apache/superset/pull/43405

   ### SUMMARY
   
   A filter configured with **Select first filter value by default: YES** and 
**Filter value is required: NO** cannot be cleared: 
`checkIsMissingRequiredValue` treats `defaultToFirstItem` as if it were 
`enableEmptyFilter`, so clearing the value disables **Apply** and shows a 
required indicator on a filter the user configured as optional. It reads as 
"the value keeps coming back", and is most visible on a filter that depends on 
a parent.
   
   ```ts
   // before — FilterBar/utils.ts
   const isRequired =
     !!filter.controlValues?.enableEmptyFilter ||
     !!filter.controlValues?.defaultToFirstItem;
   
   // after
   const isRequired = !!filter.controlValues?.enableEmptyFilter;
   ```
   
   `defaultToFirstItem` only seeds an initial selection; only 
`enableEmptyFilter` ("User must select a value before applying the filter") 
makes a value mandatory. Same change to the required-asterisk in 
`FilterControl`. Filters that are both required *and* default-first still block 
Apply, via `enableEmptyFilter`.
   
   Also drops a dead effect in `SelectFilterPlugin` — leftover from #34137, it 
computed `hasDataChanged` and then reset nothing.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A — the visible difference is the Apply button's disabled state and a red 
`*`, both covered by the added tests.
   
   ### TESTING INSTRUCTIONS
   
   1. On any dataset, add a native Value filter `Country` — required: YES, 
select first value by default: YES.
   2. Add a second native Value filter `State` — required: NO, select first 
value by default: YES, **Values are dependent on other filters: Country**.
   3. Clear `State` with the X.
   4. Before: `State` shows a red required indicator and **Apply** stays 
disabled. After: no indicator, Apply is enabled, and applying leaves `State` 
empty.
   
   Unit tests:
   
   ```
   cd superset-frontend && npx jest \
     src/dashboard/components/nativeFilters/FilterBar/utils.test.ts \
     
src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControl.test.tsx
 \
     src/filters/components/Select/SelectFilterPlugin.test.tsx
   ```
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue: No
   - [ ] Required feature flags: None
   - [x] Changes UI — the required indicator and Apply button state for 
`defaultToFirstItem` filters
   - [ ] Includes DB Migration: No — frontend only
   - [ ] Introduces new feature or API: No
   - [ ] Removes existing feature or API: No
   
   https://claude.ai/code/session_01Xm8nAHR5aG2NJT3G77Hc2C


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to