Commit 8c0f9342 authored by webchick's avatar webchick

Issue #2421581 by amateescu: Node preview causes stale values to be kept...

Issue #2421581 by amateescu: Node preview causes stale values to be kept indefinitely for exisiting nodes
parent dc5ef576
......@@ -91,6 +91,11 @@ public function form(array $form, FormStateInterface $form_state) {
$this->entity = $preview->getFormObject()->getEntity();
unset($this->entity->in_preview);
// Remove the stale temp store entry for existing nodes.
if (!$this->entity->isNew()) {
$store->delete($uuid);
}
$this->hasBeenPreviewed = TRUE;
}
......
......@@ -195,6 +195,21 @@ function testPagePreview() {
$this->assertLink($newterm2);
$this->assertNoLink($newterm3);
// Check that editing an existing node after it has been previewed and not
// saved doesn't remember the previous changes.
$edit = array(
$title_key => $this->randomMachineName(8),
);
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Preview'));
$this->assertText($edit[$title_key], 'New title displayed.');
$this->clickLink(t('Back to content editing'));
$this->assertFieldByName($title_key, $edit[$title_key], 'New title value displayed.');
// Navigate away from the node without saving.
$this->drupalGet('<front>');
// Go back to the edit form, the title should have its initial value.
$this->drupalGet('node/' . $node->id() . '/edit');
$this->assertFieldByName($title_key, $node->label(), 'Correct title value displayed.');
// Check with required preview.
$node_type = NodeType::load('page');
$node_type->setPreviewMode(DRUPAL_REQUIRED);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment