diff --git a/core/modules/user/src/Plugin/views/filter/Roles.php b/core/modules/user/src/Plugin/views/filter/Roles.php
index 014425d..e4ea2fe 100644
--- a/core/modules/user/src/Plugin/views/filter/Roles.php
+++ b/core/modules/user/src/Plugin/views/filter/Roles.php
@@ -7,7 +7,9 @@
 
 namespace Drupal\user\Plugin\views\filter;
 
+use Drupal\user\RoleStorageInterface;
 use Drupal\views\Plugin\views\filter\ManyToOne;
+use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
  * Filter handler for user roles.
@@ -18,6 +20,42 @@
  */
 class Roles extends ManyToOne {
 
+  /**
+   * The role storage.
+   *
+   * @var \Drupal\user\RoleStorageInterface
+   */
+  protected $roleStorage;
+
+  /**
+   * Constructs a Roles.
+   *
+   * @param array $configuration
+   *   A configuration array containing information about the plugin instance.
+   * @param string $plugin_id
+   *   The plugin_id for the plugin instance.
+   * @param mixed $plugin_definition
+   *   The plugin implementation definition.
+   * @param \Drupal\user\RoleStorageInterface $role_storage
+   *   The role storage.
+   */
+  public function __construct(array $configuration, $plugin_id, $plugin_definition, RoleStorageInterface $role_storage) {
+    parent::__construct($configuration, $plugin_id, $plugin_definition);
+    $this->roleStorage = $role_storage;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
+    return new static(
+      $configuration,
+      $plugin_id,
+      $plugin_definition,
+      $container->get('entity.manager')->getStorage('user_role')
+    );
+  }
+
   public function getValueOptions() {
     $this->valueOptions = user_role_names(TRUE);
     unset($this->valueOptions[DRUPAL_AUTHENTICATED_RID]);
@@ -33,4 +71,16 @@ function operators() {
     return $operators;
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function calculateDependencies() {
+    $dependencies = array();
+    foreach ($this->value as $role_id) {
+      $role_entity = $this->roleStorage->load($role_id);
+      $dependencies[$role_entity->getConfigDependencyKey()][] = $role_entity->getConfigDependencyName();
+    }
+    return $dependencies;
+  }
+
 }
diff --git a/core/modules/user/src/Tests/Views/HandlerFilterRolesTest.php b/core/modules/user/src/Tests/Views/HandlerFilterRolesTest.php
new file mode 100644
index 0000000..43bcaf4
--- /dev/null
+++ b/core/modules/user/src/Tests/Views/HandlerFilterRolesTest.php
@@ -0,0 +1,71 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\user\Tests\Views\HandlerFilterRolesTest.
+ */
+
+namespace Drupal\user\Tests\Views;
+
+use Drupal\Component\Utility\String;
+use Drupal\user\Entity\Role;
+use Drupal\user\Tests\Views\UserUnitTestBase;
+use Drupal\views\Entity\View;
+use Drupal\views\Views;
+
+/**
+ * Tests the roles filter handler.
+ *
+ * @group user
+ * @see \Drupal\user\Plugin\views\filter\Roless
+ */
+class HandlerFilterRolesTest extends UserUnitTestBase {
+
+  /**
+   * Views used by this test.
+   *
+   * @var array
+   */
+  public static $testViews = array('test_user_name');
+
+  /**
+   * Tests the roles filter handler.
+   */
+  public function testFilterRoles() {
+    $role = Role::create(['id' => 'test_user_role']);
+    $role->save();
+    $view = View::load('test_user_name');
+    $expected = [
+      'module' => ['user'],
+    ];
+    $this->assertEqual($expected, $view->getDependencies());
+
+    $display = &$view->getDisplay('default');
+    $display['display_options']['filters']['roles_target_id'] = [
+      'id' => 'roles_target_id',
+      'table' => 'user__roles',
+      'field' => 'roles_target_id',
+      'value' => [
+        'test_user_role' => 'test_user_role',
+      ],
+      'plugin_id' => 'user_roles',
+    ];
+    $view->save();
+    $expected['config'][] = 'user.role.test_user_role';
+    $this->assertEqual($expected, $view->getDependencies());
+
+    $view = View::load('test_user_name');
+    $display = &$view->getDisplay('default');
+    $display['display_options']['filters']['roles_target_id'] = [
+      'id' => 'roles_target_id',
+      'table' => 'user__roles',
+      'field' => 'roles_target_id',
+      'value' => [],
+      'plugin_id' => 'user_roles',
+    ];
+    $view->save();
+    unset($expected['config']);
+    $this->assertEqual($expected, $view->getDependencies());
+  }
+
+}
