diff --git a/core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/FilterTest.php b/core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/FilterTest.php
new file mode 100644
index 0000000..3bbf702
--- /dev/null
+++ b/core/modules/views/tests/src/FunctionalJavascript/Plugin/views/Handler/FilterTest.php
@@ -0,0 +1,132 @@
+<?php
+
+namespace Drupal\Tests\views\FunctionalJavascript\Plugin\views\Handler;
+
+use Behat\Mink\Element\NodeElement;
+use Behat\Mink\Selector\Xpath\Manipulator;
+use Drupal\field\Entity\FieldConfig;
+use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\node\Entity\NodeType;
+
+/**
+ * Tests the field field handler UI.
+ *
+ * @group views
+ */
+class FilterTest extends JavascriptTestBase {
+  /**
+   * {@inheritdoc}
+   */
+  public static $modules = ['node', 'views', 'views_ui', 'user'];
+
+  /**
+   * The account.
+   *
+   * @var \Drupal\user\UserInterface
+   */
+  protected $account;
+
+  /**
+   * {@inheritdoc}
+   */
+  protected function setUp() {
+    parent::setUp();
+
+    // Disable automatic live preview to make the sequence of calls clearer.
+    \Drupal::configFactory()->getEditable('views.settings')->set('ui.always_live_preview', FALSE)->save();
+
+    $this->account = $this->drupalCreateUser(['administer views']);
+    $this->drupalLogin($this->account);
+
+    NodeType::create([
+      'type' => 'page',
+    ])->save();
+
+    FieldConfig::create([
+      'entity_type' => 'node',
+      'field_name' => 'body',
+      'bundle' => 'page',
+    ])->save();
+  }
+
+  /**
+   * Test adding a filter handler.
+   */
+  public function testAddingFilter() {
+    $web_assert = $this->assertSession();
+    $this->drupalGet('/admin/structure/views/view/content');
+
+    $session = $this->getSession();
+    $page = $this->getSession()->getPage();
+
+    // Open the 'Add filter dialog'.
+    $page->clickLink('views-add-filter');
+    $this->waitForElement('named', array('field', 'override[controls][group]'));
+
+    // Test filtering by type.
+    $page->fillField('override[controls][group]', 'content');
+    $session->wait(1000);
+
+    $handler_rows = $page->findAll('css', 'tr.filterable-option');
+    $handler_rows = $this->filterVisibleElements($handler_rows);
+
+    foreach ($handler_rows as $handler_row) {
+      // Test that all the visible rows are of the 'content' type.
+      $this->assertTrue(strpos($handler_row->getAttribute('class'), 'content') !== FALSE);
+    }
+
+    // Search for a specific title and test that this is now the only one shown.
+    $page->fillField('override[controls][options_search]', 'body (body)');
+    $session->wait(1000);
+    $handler_rows = $page->findAll('css', 'tr.filterable-option');
+    $handler_rows = $this->filterVisibleElements($handler_rows);
+    $this->assertCount(1, $handler_rows);
+
+    // Select the body field and apply the choice.
+    $page->checkField('name[node__body.body_value]');
+    $add_button = $page->find('css', '.ui-dialog-buttonset .button--primary');
+    $add_button->click();
+
+    $this->waitForElement('named', array('field', 'options[expose_button][checkbox][checkbox]'));
+
+    $page->findField('options[expose_button][checkbox][checkbox]')->click();
+    $web_assert->assertWaitOnAjaxRequest();
+
+    $page->pressButton('Apply');
+    $web_assert->assertWaitOnAjaxRequest();
+    $web_assert->responseContains('Content: body (exposed)');
+  }
+
+  /**
+   * Waits for an element to appear on the page.
+   *
+   * @param string $selector
+   *   CSS selector.
+   * @param int $timeout
+   *   (optional) Timeout in milliseconds, defaults to 10000.
+   */
+  protected function waitForElement($selector, $locator, $timeout = 10000) {
+    $session = $this->getSession();
+    $page = $session->getPage();
+    $xpathManipulator = new Manipulator();
+
+    $xpath = $session->getSelectorsHandler()->selectorToXpath($selector, $locator);
+    $xpath = $xpathManipulator->prepend($xpath, $page->getXpath());
+
+    $condition = "document.evaluate(\"" . str_replace(PHP_EOL, '', $xpath) . "\", document, null, XPathResult.BOOLEAN_TYPE,null).booleanValue";
+    $this->assertJsCondition($condition, $timeout);
+  }
+
+  /**
+   * Removes any non-visible elements from the passed array.
+   *
+   * @param NodeElement[] $elements
+   * @return NodeElement[]
+   */
+  protected function filterVisibleElements($elements) {
+    $elements = array_filter($elements, function(NodeElement $element) {
+      return $element->isVisible();
+    });
+    return $elements;
+  }
+}
diff --git a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php
index 93bd049..7d987db 100644
--- a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php
+++ b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php
@@ -245,6 +245,9 @@ protected function ajaxFormWrapper($form_class, FormStateInterface &$form_state)
         'width' => '75%',
       );
 
+      if (!empty($form['options']['exclude'])) {
+        $response->addCommand(new CloseModalDialogCommand(TRUE));
+      }
       $response->addCommand(new OpenModalDialogCommand($title, $display, $options));
 
       // Views provides its own custom handling of AJAX form submissions.
