Issue #2321515 by dawehner: Fixed Updating links loses fragments.
parent
0d86fa90bf
commit
cdebbfb7bf
|
|
@ -260,6 +260,8 @@ class MenuLinkContentForm extends ContentEntityForm implements MenuLinkFormInter
|
||||||
// which need a replacement since it is deprecated.
|
// which need a replacement since it is deprecated.
|
||||||
// https://www.drupal.org/node/2307061
|
// https://www.drupal.org/node/2307061
|
||||||
$default_value = $url->getInternalPath();
|
$default_value = $url->getInternalPath();
|
||||||
|
}
|
||||||
|
|
||||||
// @todo Add a helper method to Url to render just the query string and
|
// @todo Add a helper method to Url to render just the query string and
|
||||||
// fragment. https://www.drupal.org/node/2305013
|
// fragment. https://www.drupal.org/node/2305013
|
||||||
$options = $url->getOptions();
|
$options = $url->getOptions();
|
||||||
|
|
@ -269,7 +271,7 @@ class MenuLinkContentForm extends ContentEntityForm implements MenuLinkFormInter
|
||||||
if (isset($options['fragment']) && $options['fragment'] !== '') {
|
if (isset($options['fragment']) && $options['fragment'] !== '') {
|
||||||
$default_value .= '#' . $options['fragment'];
|
$default_value .= '#' . $options['fragment'];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
$form['url'] = array(
|
$form['url'] = array(
|
||||||
'#title' => $this->t('Link path'),
|
'#title' => $this->t('Link path'),
|
||||||
'#type' => 'textfield',
|
'#type' => 'textfield',
|
||||||
|
|
|
||||||
|
|
@ -458,6 +458,19 @@ class MenuTest extends MenuWebTestBase {
|
||||||
$this->drupalPostForm('admin/structure/menu/item/' . $item->id() . '/edit', array('url' => $path), t('Save'));
|
$this->drupalPostForm('admin/structure/menu/item/' . $item->id() . '/edit', array('url' => $path), t('Save'));
|
||||||
$this->drupalGet('admin/structure/menu/item/' . $item->id() . '/edit');
|
$this->drupalGet('admin/structure/menu/item/' . $item->id() . '/edit');
|
||||||
$this->assertFieldByName('url', $path, 'Path no longer has query or fragment.');
|
$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.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue