diff --git a/domain/src/DomainListBuilder.php b/domain/src/DomainListBuilder.php
index 094e1377..408a2a34 100644
--- a/domain/src/DomainListBuilder.php
+++ b/domain/src/DomainListBuilder.php
@@ -9,6 +9,7 @@ use Drupal\Core\Entity\EntityTypeManagerInterface;
 use Drupal\Core\Entity\EntityStorageInterface;
 use Drupal\Core\Extension\ModuleHandlerInterface;
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Render\Element;
 use Drupal\Core\Routing\RedirectDestinationInterface;
 use Drupal\Core\Session\AccountInterface;
 use Drupal\Core\Url;
@@ -233,9 +234,7 @@ class DomainListBuilder extends DraggableListBuilder {
     if (!$this->currentUser->hasPermission('administer domains')) {
       unset($row['weight']);
     }
-    else {
-      $row['weight']['#delta'] = count($this->domainStorage->loadMultiple()) + 1;
-    }
+
     return $row;
   }
 
@@ -251,18 +250,51 @@ class DomainListBuilder extends DraggableListBuilder {
       $form['actions']['submit']['#access'] = FALSE;
       unset($form['#tabledrag']);
     }
+    // Delta is set after each row is loaded.
+    $count = count($this->domainStorage->loadMultiple()) + 1;
+    foreach (Element::children($form['domains']) as $key) {
+      if (isset($form['domains'][$key]['weight'])) {
+        $form['domains'][$key]['weight']['#delta'] = $count;
+      }
+    }
     return $form;
   }
 
   /**
    * {@inheritdoc}
+   *
+   * Overrides the parent method to prevent saving bad data.
+   *
+   * @link https://www.drupal.org/project/domain/issues/2925798
+   * @link https://www.drupal.org/project/domain/issues/2925629
    */
   public function submitForm(array &$form, FormStateInterface $form_state) {
-    parent::submitForm($form, $form_state);
+    // Do not let the form reorder domain weights incorrectly.
+    $i = 1;
+    $domains = $form_state->getValue('domains');
+    uasort($domains, [$this, 'sortByWeight']);
+    foreach ($domains as $id => $value) {
+      // Save the weight values of each entity.
+      $this->entities[$id]->set('weight', $i);
+      // Do not allow accidental hostname rewrites.
+      $this->entities[$id]->set('hostname', $this->entities[$id]->getCanonical());
+      $this->entities[$id]->save();
+      $i++;
+    }
     drupal_set_message($this->t('Configuration saved.'));
   }
 
   /**
+   * Internal sort method for form weights.
+   */
+  private function sortByWeight($a, $b) {
+    if ($a['weight'] < $b['weight']) {
+      return 0;
+    }
+    return 1;
+  }
+
+  /**
    * {@inheritdoc}
    *
    * Builds the entity listing as a form with pagination. This method overrides both
