Commit 4dee1624 authored by lauriii's avatar lauriii

Issue #2910005 by catch, samuel.mortenson: JavaScript errors thrown when...

Issue #2910005 by catch, samuel.mortenson: JavaScript errors thrown when viewing non-latest default revision of entity
parent 210ca8a1
......@@ -129,14 +129,14 @@ function quickedit_preprocess_page_title(&$variables) {
*/
function quickedit_preprocess_field(&$variables) {
$variables['#cache']['contexts'][] = 'user.permissions';
if (!\Drupal::currentUser()->hasPermission('access in-place editing')) {
return;
}
$element = $variables['element'];
/** @var $entity \Drupal\Core\Entity\EntityInterface */
$entity = $element['#object'];
if (!\Drupal::currentUser()->hasPermission('access in-place editing') || !_quickedit_entity_is_latest_revision($entity)) {
return;
}
// Quick Edit module only supports view modes, not dynamically defined
// "display options" (which \Drupal\Core\Field\FieldItemListInterface::view()
// always names the "_custom" view mode).
......
......@@ -332,6 +332,7 @@ public function testWithPendingRevision() {
$this->drupalGet('node/' . $this->testNode->id());
$this->assertRaw('data-quickedit-entity-id="node/' . $this->testNode->id() . '"');
$this->assertRaw('data-quickedit-field-id="node/' . $this->testNode->id() . '/title/' . $this->testNode->language()->getId() . '/full"');
$this->testNode->title = 'Updated node';
$this->testNode->setNewRevision(TRUE);
......@@ -340,6 +341,7 @@ public function testWithPendingRevision() {
$this->drupalGet('node/' . $this->testNode->id());
$this->assertNoRaw('data-quickedit-entity-id="node/' . $this->testNode->id() . '"');
$this->assertNoRaw('data-quickedit-field-id="node/' . $this->testNode->id() . '/title/' . $this->testNode->language()->getId() . '/full"');
}
/**
......
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