diff --git a/views_ui/admin.inc b/views_ui/admin.inc
index 0e6172fd72e19d014340c8433b16d923e3683c9c..68253ff9548a36eff2e5d56a93aa00f59c6eea4a 100644
--- a/views_ui/admin.inc
+++ b/views_ui/admin.inc
@@ -809,6 +809,12 @@ function views_ui_build_form_url($form_state) {
  * together.
  */
 function views_ui_ajax_form($js, $key, ViewUI $view, $display_id = '') {
+  // Reset the cache of IDs. Drupal rather aggressively prevents ID
+  // duplication but this causes it to remember IDs that are no longer even
+  // being used.
+  $seen_ids_init = &drupal_static('drupal_html_id:init');
+  $seen_ids_init = array();
+
   $form = views_ui_ajax_forms($key);
   if (empty($form)) {
     return MENU_NOT_FOUND;
diff --git a/views_ui/lib/Drupal/views_ui/ViewUI.php b/views_ui/lib/Drupal/views_ui/ViewUI.php
index 6c92498833e109dff7eb06783380b19c66000da7..3547b64881e44bd93857a67e08e8c8c21dacb306 100644
--- a/views_ui/lib/Drupal/views_ui/ViewUI.php
+++ b/views_ui/lib/Drupal/views_ui/ViewUI.php
@@ -1428,6 +1428,12 @@ public function buildEditForm($form, &$form_state, $display_id = NULL) {
    * Provide the preview formulas and the preview output, too.
    */
   public function buildPreviewForm($form, &$form_state, $display_id = 'default') {
+    // Reset the cache of IDs. Drupal rather aggressively prevents ID
+    // duplication but this causes it to remember IDs that are no longer even
+    // being used.
+    $seen_ids_init = &drupal_static('drupal_html_id:init');
+    $seen_ids_init = array();
+
     $form_state['no_cache'] = TRUE;
     $form_state['view'] = $this;
 
@@ -1590,6 +1596,12 @@ public function submitDisplaysReorderForm($form, &$form_state) {
    * rather than closing the ajax popup.
    */
   public function addFormToStack($key, $display_id, $args, $top = FALSE, $rebuild_keys = FALSE) {
+    // Reset the cache of IDs. Drupal rather aggressively prevents ID
+    // duplication but this causes it to remember IDs that are no longer even
+    // being used.
+    $seen_ids_init = &drupal_static('drupal_html_id:init');
+    $seen_ids_init = array();
+
     if (empty($this->stack)) {
       $this->stack = array();
     }