diff --git a/src/plugins/workspace/public/components/workspace_detail/association_data_source_modal.tsx b/src/plugins/workspace/public/components/workspace_detail/association_data_source_modal.tsx index 037eaeae8d2..3eec04d5ae5 100644 --- a/src/plugins/workspace/public/components/workspace_detail/association_data_source_modal.tsx +++ b/src/plugins/workspace/public/components/workspace_detail/association_data_source_modal.tsx @@ -163,14 +163,9 @@ export const AssociationDataSourceModal = ({ ); const isParentCheckedThisTime = newCheckedConnectionIds.includes(parentConnection.id); - // Parent change to checked this time - if (!isParentCheckedLastTime && isParentCheckedThisTime) { - option.checked = 'on'; - } - - // This won't be executed since checked options already been filter out - if (isParentCheckedLastTime && isParentCheckedThisTime) { - option.checked = undefined; + // Update checked status if parent checked status changed this time + if (isParentCheckedLastTime !== isParentCheckedThisTime) { + option.checked = isParentCheckedThisTime ? 'on' : undefined; } } }