diff --git a/src/Plugin/search_api/datasource/ContentEntity.php b/src/Plugin/search_api/datasource/ContentEntity.php
index 37ac2fa2..33c62d68 100644
--- a/src/Plugin/search_api/datasource/ContentEntity.php
+++ b/src/Plugin/search_api/datasource/ContentEntity.php
@@ -931,62 +931,6 @@ protected function getPropertyPathDependencies($property_path, array $properties
   /**
    * {@inheritdoc}
    */
-  public function getFieldDependenciesForEntityType($entity_type_id, array $fields, array $all_fields) {
-    $field_dependencies = array();
-
-    // Figure out which fields are directly on the item and which need to be
-    // extracted from nested items.
-    $direct_fields = array();
-    $nested_fields = array();
-    foreach ($fields as $field) {
-      if (strpos($field, ':entity:') !== FALSE) {
-        list($direct, $nested) = explode(':entity:', $field, 2);
-        $nested_fields[$direct][] = $nested;
-      }
-      else {
-        // Support nested Search API fields.
-        $base_field_name = explode(':', $field, 2)[0];
-        $direct_fields[$base_field_name] = TRUE;
-      }
-    }
-
-    // Extract the config dependency name for direct fields.
-    foreach (array_keys($this->getEntityTypeBundleInfo()->getBundleInfo($entity_type_id)) as $bundle) {
-      foreach ($this->getEntityFieldManager()->getFieldDefinitions($entity_type_id, $bundle) as $field_name => $field_definition) {
-        if ($field_definition instanceof FieldConfigInterface) {
-          if (isset($direct_fields[$field_name]) || isset($nested_fields[$field_name])) {
-            // Make a mapping of dependencies and fields that depend on them.
-            $storage_definition = $field_definition->getFieldStorageDefinition();
-            if (!$storage_definition instanceof EntityInterface) {
-              continue;
-            }
-            $dependency = $storage_definition->getConfigDependencyName();
-            $search_api_fields = array();
-
-            // Get a list of enabled fields on the datasource.
-            foreach ($all_fields as $field_id => $property_path) {
-              if (strpos($property_path, $field_definition->getName()) !== FALSE) {
-                $search_api_fields[] = $field_id;
-              }
-            }
-            $field_dependencies[$dependency] = $search_api_fields;
-          }
-
-          // Recurse for nested fields.
-          if (isset($nested_fields[$field_name])) {
-            $entity_type = $field_definition->getSetting('target_type');
-            $field_dependencies += $this->getFieldDependenciesForEntityType($entity_type, $nested_fields[$field_name], $all_fields);
-          }
-        }
-      }
-    }
-
-    return $field_dependencies;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
   public static function getIndexesForEntity(ContentEntityInterface $entity) {
     $entity_type = $entity->getEntityTypeId();
     $datasource_id = 'entity:' . $entity_type;
diff --git a/src/Plugin/search_api/datasource/EntityDatasourceInterface.php b/src/Plugin/search_api/datasource/EntityDatasourceInterface.php
index 1101ca76..82bf4878 100644
--- a/src/Plugin/search_api/datasource/EntityDatasourceInterface.php
+++ b/src/Plugin/search_api/datasource/EntityDatasourceInterface.php
@@ -41,20 +41,4 @@ public static function getIndexesForEntity(ContentEntityInterface $entity);
    */
   public function getPartialItemIds($page = NULL, array $bundles = NULL, array $languages = NULL);
 
-  /**
-   * Returns an array of config entity dependencies.
-   *
-   * @param string $entity_type_id
-   *   The entity type to which the fields are attached.
-   * @param string[] $fields
-   *   An array of property paths of fields from this entity type.
-   * @param string[] $all_fields
-   *   An array of property paths of all the fields from this datasource.
-   *
-   * @return string[]
-   *   An array keyed by the IDs of entities on which this datasource depends.
-   *   The values are containing list of Search API fields.
-   */
-  public function getFieldDependenciesForEntityType($entity_type_id, array $fields, array $all_fields);
-
 }
diff --git a/tests/src/Kernel/DependencyRemovalTest.php b/tests/src/Kernel/DependencyRemovalTest.php
index 4388efdd..79208229 100644
--- a/tests/src/Kernel/DependencyRemovalTest.php
+++ b/tests/src/Kernel/DependencyRemovalTest.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\Tests\search_api\Kernel;
 
+use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
 use Drupal\KernelTests\KernelTestBase;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\field\Entity\FieldStorageConfig;
@@ -17,6 +18,7 @@
  */
 class DependencyRemovalTest extends KernelTestBase {
 
+  use EntityReferenceTestTrait;
   use PluginTestTrait;
 
   /**
@@ -83,7 +85,10 @@ public function setUp() {
    * Tests index with a field dependency that gets removed.
    */
   public function testFieldDependency() {
-    // Add new field storage and field definitions.
+    // Add new field storage and field definitions. Use an indirect reference
+    // for the field to test whether this can also be handled correctly.
+    $this->createEntityReferenceField('user', 'user', 'parent', 'Parent', 'user');
+    $parent_field_storage = FieldStorageConfig::loadByName('user', 'parent');
     /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */
     $field_storage = FieldStorageConfig::create(array(
       'field_name' => 'field_search',
@@ -100,15 +105,32 @@ public function testFieldDependency() {
     ));
     $field_search->save();
 
-    // Create a Search API field/item and add it to the current index.
-    $field = Utility::createFieldFromProperty($this->index, $field_storage->getPropertyDefinition('value'), 'entity:user', 'field_search', NULL, 'string');
-    $field->setLabel('Search Field');
+    // Add fields to the index.
+    $fields_helper = \Drupal::getContainer()->get('search_api.fields_helper');
+    $field = $fields_helper->createFieldFromProperty($this->index, $field_storage->getPropertyDefinition('value'), 'entity:user', 'field_search', 'search', 'string');
+    $this->index->addField($field);
+    $field = $fields_helper->createFieldFromProperty($this->index, $field_storage->getPropertyDefinition('value'), 'entity:user', 'parent:entity:field_search', 'parent_search', 'string');
+    $this->index->addField($field);
+    $field = $fields_helper->createFieldFromProperty($this->index, $parent_field_storage->getPropertyDefinition('target_id'), 'entity:user', 'parent', 'parent', 'string');
     $this->index->addField($field);
     $this->index->save();
 
     // New field has been added to the list of dependencies.
     $config_dependencies = \Drupal::config('search_api.index.' . $this->index->id())->get('dependencies.config');
+    $this->assertContains($parent_field_storage->getConfigDependencyName(), $config_dependencies);
+    $this->assertContains($field_storage->getConfigDependencyName(), $config_dependencies);
+
+    // Remove a dependent field.
+    $parent_field_storage->delete();
+
+    // Index has not been deleted and index dependencies were updated.
+    $this->reloadIndex();
+    $index = \Drupal::config('search_api.index.' . $this->index->id());
+    $dependencies = $index->get('dependencies');
+    $this->assertFalse(isset($dependencies['config'][$parent_field_storage->getConfigDependencyName()]));
     $this->assertContains($field_storage->getConfigDependencyName(), $config_dependencies);
+    // Correct fields were removed.
+    $this->assertEquals(['search'], array_keys($index->get('field_settings')));
 
     // Remove a dependent field.
     $field_storage->delete();
@@ -117,6 +139,8 @@ public function testFieldDependency() {
     $this->reloadIndex();
     $dependencies = \Drupal::config('search_api.index.' . $this->index->id())->get('dependencies');
     $this->assertFalse(isset($dependencies['config'][$field_storage->getConfigDependencyName()]));
+    // Last field was removed.
+    $this->assertEquals([], array_keys($index->get('field_settings')));
   }
 
   /**
