@@ -46,7 +46,7 @@ import { useDispatch, useSelector } from 'react-redux';
4646import { isEqual , isEqualWith } from 'lodash' ;
4747import { getChartDataRequest } from 'src/components/Chart/chartAction' ;
4848import { ErrorAlert , ErrorMessageWithStackTrace } from 'src/components' ;
49- import { Loading , Constants } from '@superset-ui/core/components' ;
49+ import { Loading , Constants , Flex } from '@superset-ui/core/components' ;
5050import { waitForAsyncData } from 'src/middleware/asyncEvent' ;
5151import { FilterBarOrientation , RootState } from 'src/dashboard/types' ;
5252import {
@@ -128,6 +128,8 @@ const FilterValue: FC<FilterValueProps> = ({
128128 [ isCustomization ] ,
129129 ) ;
130130 const [ state , setState ] = useState < ChartDataResponseResult [ ] > ( [ ] ) ;
131+ const hasDeps = Boolean ( filter . cascadeParentIds ?. length ) ;
132+ const [ hasDepsFilterValue , setHasDepsFilterValue ] = useState ( hasDeps ) ;
131133 const dashboardId = useSelector < RootState , number > (
132134 state => state . dashboardInfo . id ,
133135 ) ;
@@ -160,6 +162,10 @@ const FilterValue: FC<FilterValueProps> = ({
160162 }
161163 } , [ dispatch , shouldRefresh ] ) ;
162164
165+ useEffect ( ( ) => {
166+ setHasDepsFilterValue ( hasDeps ) ;
167+ } , [ hasDeps ] ) ;
168+
163169 useEffect ( ( ) => {
164170 if ( ! inViewFirstTime && inView ) {
165171 setInViewFirstTime ( true ) ;
@@ -185,28 +191,31 @@ const FilterValue: FC<FilterValueProps> = ({
185191 // Prevent unnecessary backend requests by validating parent filter selections first
186192
187193 let selectedParentFilterValueCounts = 0 ;
188-
194+ let isTimeRangeSelected = false ;
189195 ( filter . cascadeParentIds ?? [ ] ) . forEach ( pId => {
190196 const extraFormData = dataMaskSelected ?. [ pId ] ?. extraFormData ;
191197 if ( extraFormData ?. filters ?. length ) {
192198 selectedParentFilterValueCounts += extraFormData . filters . length ;
193- } else if ( extraFormData ?. time_range ) {
194- selectedParentFilterValueCounts += 1 ;
199+ }
200+ if ( extraFormData ?. time_range ) {
201+ isTimeRangeSelected = true ;
195202 }
196203 } ) ;
197204
198205 // check if all parent filters with defaults have a value selected
199206
200- let depsCount = dependencies . filters ?. length ?? 0 ;
207+ const depsCount = dependencies . filters ?. length ?? 0 ;
208+ const hasTimeRangeDeps = Boolean ( dependencies ?. time_range ) ;
201209
202- if ( dependencies ?. time_range ) {
203- depsCount += 1 ;
204- }
205- if ( selectedParentFilterValueCounts !== depsCount ) {
210+ if (
211+ selectedParentFilterValueCounts !== depsCount ||
212+ ( hasTimeRangeDeps && ! isTimeRangeSelected )
213+ ) {
206214 // child filter should not request backend until it
207215 // has all the required information from parent filters
208216 return ;
209217 }
218+ setHasDepsFilterValue ( false ) ;
210219 }
211220
212221 // TODO: We should try to improve our useEffect hooks to depend more on
@@ -281,6 +290,7 @@ const FilterValue: FC<FilterValueProps> = ({
281290 isRefreshing ,
282291 shouldRefresh ,
283292 dataMaskSelected ,
293+ setHasDepsFilterValue ,
284294 ] ) ;
285295
286296 useEffect ( ( ) => {
@@ -397,7 +407,12 @@ const FilterValue: FC<FilterValueProps> = ({
397407 overflow = { overflow }
398408 >
399409 { isLoading ? (
400- < Loading position = "inline-centered" size = "s" muted />
410+ < Flex align = "center" >
411+ < Loading position = "inline" size = "s" muted />
412+ { hasDepsFilterValue
413+ ? t ( 'Awaiting filter selection' )
414+ : t ( 'Loading filter values' ) }
415+ </ Flex >
401416 ) : (
402417 < SuperChart
403418 height = { HEIGHT }
0 commit comments