villebro commented on a change in pull request #14710:
URL: https://github.com/apache/superset/pull/14710#discussion_r637849339
##########
File path:
superset-frontend/src/filters/components/Select/SelectFilterPlugin.tsx
##########
@@ -53,33 +109,68 @@ export default function PluginFilterSelect(props:
PluginFilterSelectProps) {
inverseSelection,
inputRef,
defaultToFirstItem,
+ searchAllOptions,
} = formData;
- const forceFirstValue =
+ const isDisabled =
appSection === AppSection.FILTER_CONFIG_MODAL && defaultToFirstItem;
const groupby = ensureIsArray<string>(formData.groupby);
// Correct initial value for Ant Select
- const initSelectValue: SelectValue =
- // `defaultValue` can be `FIRST_VALUE` if `defaultToFirstItem` is checked,
so need convert it to correct value for Select
- defaultValue === FIRST_VALUE ? [] : defaultValue ?? [];
-
- const firstItem: SelectValue = data[0]
- ? (groupby.map(col => data[0][col]) as string[]) ?? initSelectValue
- : initSelectValue;
// If we are in config modal we always need show empty select for
`defaultToFirstItem`
- const [values, setValues] = useState<SelectValue>(
- defaultToFirstItem && appSection !== AppSection.FILTER_CONFIG_MODAL
- ? firstItem
- : initSelectValue,
- );
+ const [values, setValues] = useState<SelectValue>([]);
const [currentSuggestionSearch, setCurrentSuggestionSearch] = useState('');
+ const [dataMask, dispatchDataMask] = useReducer<DataMaskReducer>(reducer,
{});
+
+ const searchWrapper = (val: string) => {
+ if (searchAllOptions) {
+ debouncedOwnStateFunc(dispatchDataMask, val);
+ }
+ setCurrentSuggestionSearch(val);
+ };
const clearSuggestionSearch = () => {
setCurrentSuggestionSearch('');
+ if (searchAllOptions) {
+ dispatchDataMask({
+ type: 'ownState',
+ ownState: {
+ search: null,
+ },
+ });
+ }
};
+ useEffect(() => {
+ if (!isDisabled && defaultValue?.length) {
+ // initialize to default value
+ setValues(defaultValue);
+ }
+ // initialize column types (these should only be set once)
Review comment:
I added it to the deps in the `defaultValue` use effect.
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]