@@ -193,34 +193,36 @@ export class DataReferenceComponent extends ContainerBaseComponent {
193193
194194
195195 #setChildDatasource( ) {
196- const { type, config } = this . firstChildMeta ;
197-
198- // Early exit: AutoComplete has its own simple datasource logic
196+ const { type } = this . firstChildMeta ;
197+
199198 if ( type === 'AutoComplete' ) {
200- config . datasource = this . refList ;
201-
202- const hasParameters = this . rawViewMetadata . config ?. parameters ;
203- if ( hasParameters ) {
204- config . parameters = this . parameters ;
205- }
206- return ;
199+ this . #setAutoCompleteDatasource( ) ;
200+ } else if ( [ 'Dropdown' , 'Checkbox' ] . includes ( type ) ) {
201+ this . #setDropdownOrCheckboxDatasource( ) ;
207202 }
208-
209- // Early exit: Only handle Dropdown and Checkbox with non-deferred datasources
210- const isDropdownOrCheckbox = [ 'Dropdown' , 'Checkbox' ] . includes ( type ) ;
211- const hasDatasource = config . datasource ;
212- const shouldLoadImmediately = ! config . deferDatasource ;
213-
214- if ( ! isDropdownOrCheckbox || ! hasDatasource || ! shouldLoadImmediately ) {
203+ }
204+
205+ #setAutoCompleteDatasource( ) {
206+ const { config } = this . firstChildMeta ;
207+ config . datasource = this . refList ;
208+
209+ const hasParameters = this . rawViewMetadata . config ?. parameters ;
210+ if ( hasParameters ) {
211+ config . parameters = this . parameters ;
212+ }
213+ }
214+
215+ #setDropdownOrCheckboxDatasource( ) {
216+ const { config } = this . firstChildMeta ;
217+
218+ if ( ! config . datasource || config . deferDatasource ) {
215219 return ;
216220 }
217-
218- // Set datasource based on whether parameters are configured
221+
219222 const hasParameters = this . rawViewMetadata . config ?. parameters ;
220- const preloadedDataSource = this . dropDownDataSource ;
221- const dynamicDataSourcePath = `@DATASOURCE ${ this . refList } .pxResults` ;
222-
223- config . datasource . source = hasParameters ? preloadedDataSource : dynamicDataSourcePath ;
223+ config . datasource . source = hasParameters
224+ ? this . dropDownDataSource
225+ : `@DATASOURCE ${ this . refList } .pxResults` ;
224226 }
225227
226228 // Re-create first child with overridden props
0 commit comments