diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
index 79b9292..16185a2 100644
--- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
+++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
@@ -435,6 +435,8 @@ public function onDependencyRemoval(array $dependencies) {
           $this->setComponent($name);
           $changed = TRUE;
         }
+        // Allow components to react on dependency removals.
+        $changed |= $this->getRenderer($name)->onDependencyRemoval($dependencies);
       }
     }
     return $changed;
diff --git a/core/lib/Drupal/Core/Field/PluginSettingsBase.php b/core/lib/Drupal/Core/Field/PluginSettingsBase.php
index 1baf31d..8e12df3 100644
--- a/core/lib/Drupal/Core/Field/PluginSettingsBase.php
+++ b/core/lib/Drupal/Core/Field/PluginSettingsBase.php
@@ -122,4 +122,11 @@ public function calculateDependencies() {
     return array();
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function onDependencyRemoval(array $dependencies) {
+    return FALSE;
+  }
+
 }
diff --git a/core/lib/Drupal/Core/Field/PluginSettingsInterface.php b/core/lib/Drupal/Core/Field/PluginSettingsInterface.php
index 969061f..5884a5e 100644
--- a/core/lib/Drupal/Core/Field/PluginSettingsInterface.php
+++ b/core/lib/Drupal/Core/Field/PluginSettingsInterface.php
@@ -95,4 +95,28 @@ public function getThirdPartySetting($module, $key, $default = NULL);
    */
   public function setThirdPartySetting($module, $key, $value);
 
+  /**
+   * Provides actions when is called to react on removal of its dependencies.
+   *
+   * This method allows plugins to keep their configuration up-to-date when a
+   * dependency calculated with ::calculateDependencies() is removed. For
+   * example, an entity view display contains a formatter having a setting
+   * pointing to an arbitrary config entity. When that config entity is deleted,
+   * this method is called by the view display to react on the dependency
+   * removal by updating its configuration.
+   *
+   * This method returns TRUE if the removal event updated the plugin
+   * configuration.
+   *
+   * @param array $dependencies
+   *   An array of dependencies that will be deleted keyed by dependency type.
+   *   Dependency types are, for example, entity, module and theme.
+   *
+   * @return bool
+   *   TRUE if the plugin configuration has changed, FALSE if not.
+   *
+   * @see \Drupal\Core\Entity\EntityDisplayBase
+   */
+  public function onDependencyRemoval(array $dependencies);
+
 }
diff --git a/core/modules/field/tests/modules/field_test/config/schema/field_test.schema.yml b/core/modules/field/tests/modules/field_test/config/schema/field_test.schema.yml
index 8e06db1..d864369 100644
--- a/core/modules/field/tests/modules/field_test/config/schema/field_test.schema.yml
+++ b/core/modules/field/tests/modules/field_test/config/schema/field_test.schema.yml
@@ -40,6 +40,9 @@ field.widget.settings.test_field_widget:
     test_widget_setting:
       type: string
       label: 'Test setting'
+    role:
+      type: string
+      label: 'A referenced role'
 
 field.widget.settings.test_field_widget_multiple:
   type: mapping
@@ -48,6 +51,9 @@ field.widget.settings.test_field_widget_multiple:
     test_widget_setting_multiple:
       type: string
       label: 'Test setting'
+    role:
+      type: string
+      label: 'A referenced role'
 
 field.storage_settings.test_field:
   type: mapping
diff --git a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php
index b90008a..d68954d 100644
--- a/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php
+++ b/core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldWidget/TestFieldWidget.php
@@ -34,6 +34,7 @@ class TestFieldWidget extends WidgetBase {
   public static function defaultSettings() {
     return array(
       'test_widget_setting' => 'dummy test string',
+      'role' => 'anonymous',
     ) + parent::defaultSettings();
   }
 
@@ -78,4 +79,32 @@ public function errorElement(array $element, ConstraintViolationInterface $viola
     return $element['value'];
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function calculateDependencies() {
+    $dependencies = parent::calculateDependencies();
+    if (!empty($role_id = $this->getSetting('role'))) {
+      // Create a dependency on the role config entity referenced in settings.
+      $dependencies['config'][] = "user.role.$role_id";
+    }
+    return $dependencies;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function onDependencyRemoval(array $dependencies) {
+    $changed = parent::onDependencyRemoval($dependencies);
+
+    if (!empty($role_id = $this->getSetting('role'))) {
+      if (!empty($dependencies['config']["user.role.$role_id"])) {
+        $this->setSetting('role', 'anonymous');
+        $changed = TRUE;
+      }
+    }
+
+    return $changed;
+  }
+
 }
diff --git a/core/modules/field_ui/src/Tests/EntityDisplayTest.php b/core/modules/field_ui/src/Tests/EntityDisplayTest.php
index 82dc8ab..265eab4 100644
--- a/core/modules/field_ui/src/Tests/EntityDisplayTest.php
+++ b/core/modules/field_ui/src/Tests/EntityDisplayTest.php
@@ -7,12 +7,16 @@
 
 namespace Drupal\field_ui\Tests;
 
+use Drupal\Component\Utility\Unicode;
+use Drupal\Core\Entity\Display\EntityDisplayInterface;
+use Drupal\Core\Entity\Entity\EntityFormDisplay;
 use Drupal\Core\Entity\Entity\EntityViewDisplay;
 use Drupal\Core\Entity\Entity\EntityViewMode;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\field\Entity\FieldStorageConfig;
 use Drupal\node\Entity\NodeType;
 use Drupal\simpletest\KernelTestBase;
+use Drupal\user\Entity\Role;
 
 /**
  * Tests the entity display configuration entities.
@@ -435,4 +439,88 @@ public function testOnDependencyRemoval() {
     $display = entity_get_display('entity_test', 'entity_test', 'default');
     $this->assertFalse($display->getComponent($field_name));
   }
+
+  /**
+   * Tests components dependencies additions.
+   */
+  public function testComponentDependencies() {
+    $this->installEntitySchema('user');
+    // Create an arbitrary user role.
+    $role = Role::create([
+      'id' => Unicode::strtolower($this->randomMachineName()),
+      'label' => $this->randomString(),
+    ]);
+    $role->save();
+
+    // Create a field of type 'test_field' attached to 'entity_test'.
+    $field_name = Unicode::strtolower($this->randomMachineName());
+    FieldStorageConfig::create([
+      'field_name' => $field_name,
+      'entity_type' => 'entity_test',
+      'type' => 'test_field',
+    ])->save();
+    FieldConfig::create([
+      'field_name' => $field_name,
+      'entity_type' => 'entity_test',
+      'bundle' => 'entity_test',
+    ])->save();
+
+    // Create a new form display without components.
+    /** @var \Drupal\Core\Entity\Display\EntityFormDisplayInterface $form_display */
+    $form_display = EntityFormDisplay::create([
+      'targetEntityType' => 'entity_test',
+      'bundle' => 'entity_test',
+      'mode' => 'default',
+    ]);
+    $form_display->save();
+
+    $dependency = 'user.role.' . $role->id();
+
+    // The config object should not depend on user role $role.
+    $this->assertFalse($this->isConfigDependency($dependency, $form_display));
+
+    // Add a widget of type 'test_field_widget'.
+    $component = [
+      'type' => 'test_field_widget',
+      'settings' => [
+        'test_widget_setting' => $this->randomString(),
+        'role' => $role->id(),
+      ],
+    ];
+    $form_display->setComponent($field_name, $component);
+    $form_display->save();
+
+    // Now, the form display should depend on user role $role.
+    $this->assertTrue($this->isConfigDependency($dependency, $form_display));
+
+    // Delete the dependency user role entity.
+    $role->delete();
+
+    // Reload the form display.
+    EntityFormDisplay::load($form_display->id());
+    // The form display should not depend on $role anymore.
+    $this->assertFalse($this->isConfigDependency($dependency, $form_display));
+    // The form display should depend on 'anonymous' user role.
+    $this->assertTrue($this->isConfigDependency('user.role.anonymous', $form_display));
+  }
+
+  /**
+   * Returns TRUE if $key is a config dependency of $entity_display.
+   *
+   * @param string $key
+   *   The string to be checked.
+   * @param \Drupal\Core\Entity\Display\EntityDisplayInterface $entity_display
+   *   The entity display object to get dependencies from.
+   *
+   * @return bool
+   *   If the supplied $key is a config dependency of the $entity_display.
+   *
+   * @see testComponentDependencies()
+   */
+  protected function isConfigDependency($key, EntityDisplayInterface $entity_display) {
+    $dependencies = $entity_display->getDependencies();
+    $config_dependencies = !empty($dependencies['config']) ? $dependencies['config'] : [];
+    return in_array($key, $config_dependencies);
+  }
+
 }
