diff --git a/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php b/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php
index ce2d81ddaf8ccc222d2d06b3acfbf645cc2c8a6b..b3966eba12bcabfcad64d8398186500ce4358120 100644
--- a/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php
+++ b/core/modules/menu_link_content/src/Form/MenuLinkContentForm.php
@@ -260,16 +260,18 @@ public function form(array $form, FormStateInterface $form_state) {
       // which need a replacement since it is deprecated.
       // https://www.drupal.org/node/2307061
       $default_value = $url->getInternalPath();
-      // @todo Add a helper method to Url to render just the query string and
-      // fragment. https://www.drupal.org/node/2305013
-      $options = $url->getOptions();
-      if (isset($options['query'])) {
-        $default_value .= $options['query'] ? ('?' . UrlHelper::buildQuery($options['query'])) : '';
-      }
-      if (isset($options['fragment']) && $options['fragment'] !== '') {
-        $default_value .= '#' . $options['fragment'];
-      }
     }
+
+    // @todo Add a helper method to Url to render just the query string and
+    // fragment. https://www.drupal.org/node/2305013
+    $options = $url->getOptions();
+    if (isset($options['query'])) {
+      $default_value .= $options['query'] ? ('?' . UrlHelper::buildQuery($options['query'])) : '';
+    }
+    if (isset($options['fragment']) && $options['fragment'] !== '') {
+      $default_value .= '#' . $options['fragment'];
+    }
+
     $form['url'] = array(
       '#title' => $this->t('Link path'),
       '#type' => 'textfield',
diff --git a/core/modules/menu_ui/src/Tests/MenuTest.php b/core/modules/menu_ui/src/Tests/MenuTest.php
index 617936315795881a2333fbbe9fe426e853db23dd..54bfd000e00a36b915783dae3186873dd840a4df 100644
--- a/core/modules/menu_ui/src/Tests/MenuTest.php
+++ b/core/modules/menu_ui/src/Tests/MenuTest.php
@@ -458,6 +458,19 @@ function testMenuQueryAndFragment() {
     $this->drupalPostForm('admin/structure/menu/item/' . $item->id() . '/edit', array('url' => $path), t('Save'));
     $this->drupalGet('admin/structure/menu/item/' . $item->id() . '/edit');
     $this->assertFieldByName('url', $path, 'Path no longer has query or fragment.');
+
+    // Use <front>#fragment and ensure that saving it does not loose its
+    // content.
+    $path = '<front>?arg1=value#fragment';
+    $item = $this->addMenuLink('', $path);
+
+    $this->drupalGet('admin/structure/menu/item/' . $item->id() . '/edit');
+    $this->assertFieldByName('url', $path, 'Path is found with both query and fragment.');
+
+    $this->drupalPostForm('admin/structure/menu/item/' . $item->id() . '/edit', array(), t('Save'));
+
+    $this->drupalGet('admin/structure/menu/item/' . $item->id() . '/edit');
+    $this->assertFieldByName('url', $path, 'Path is found with both query and fragment.');
   }
 
   /**