core/modules/edit/js/views/EntityToolbarView.js | 16 +++++++++++++--- .../lib/Drupal/node/Controller/NodeViewController.php | 6 +++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/core/modules/edit/js/views/EntityToolbarView.js b/core/modules/edit/js/views/EntityToolbarView.js index 064c6cd..48533f3 100644 --- a/core/modules/edit/js/views/EntityToolbarView.js +++ b/core/modules/edit/js/views/EntityToolbarView.js @@ -203,9 +203,19 @@ delay = 250; break; default: - // Position against the entity, or as a last resort, the body element. - of = this.$entity || 'body'; - delay = 750; + var fieldModels = this.model.get('fields').models; + var topMostPosition = 1000000; + var topMostField = null; + // Position against the topmost field. + for (var i = 0; i < fieldModels.length; i++) { + var pos = fieldModels[i].get('el').getBoundingClientRect().top; + if (pos < topMostPosition) { + topMostPosition = pos; + topMostField = fieldModels[i]; + } + } + of = topMostField.get('el'); + delay = 50; break; } // Prepare to check the next possible element to position against. diff --git a/core/modules/node/lib/Drupal/node/Controller/NodeViewController.php b/core/modules/node/lib/Drupal/node/Controller/NodeViewController.php index 5749b72..98f1114 100644 --- a/core/modules/node/lib/Drupal/node/Controller/NodeViewController.php +++ b/core/modules/node/lib/Drupal/node/Controller/NodeViewController.php @@ -7,8 +7,8 @@ namespace Drupal\node\Controller; +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\Controller\EntityViewController; -use Drupal\node\NodeInterface; /** * Defines a generic controller to render a single entity. @@ -18,13 +18,13 @@ class NodeViewController extends EntityViewController { /** * Displays a node. * - * @param \Drupal\node\NodeInterface $node + * @param \Drupal\node\EntityInterface $node * The node we are displaying. * * @return array * An array suitable for drupal_render(). */ - public function view(NodeInterface $node) { + public function view(EntityInterface $node, $view_mode = 'full', $langcode = NULL) { $build = array('nodes' => parent::view($node)); $build['#title'] = $build['nodes']['#title'];