diff --git a/js/edit_plus/plugins/field-plugin-base.js b/js/edit_plus/plugins/field-plugin-base.js index 6bd50724751c247f32ab50587745a7709d0f7c58..f7e409438e6f454fe89de32c9f9c0954c6d9a1f2 100644 --- a/js/edit_plus/plugins/field-plugin-base.js +++ b/js/edit_plus/plugins/field-plugin-base.js @@ -338,13 +338,16 @@ export class FieldPluginBase { sizedPlaceholder.classList.add('sized-placeholder'); pageElement.parentElement.insertBefore(sizedPlaceholder, pageElement); - this.positionFormItemOverPageElement(); - document.addEventListener('scroll', this.positionFormItemOverPageElement); - window.addEventListener('resize', this.positionFormItemOverPageElement); + pageElement.classList.add('edit-plus-hidden'); + formItem.classList.add('edit-plus-editing'); // Make the sized placeholder the same height as the form item. sizedPlaceholder.style.height = formItem.getBoundingClientRect().height + 'px'; + this.positionFormItemOverPageElement(); + document.addEventListener('scroll', this.positionFormItemOverPageElement); + window.addEventListener('resize', this.positionFormItemOverPageElement); + // Ensure the sizedPlaceholder height stays in sync with the formItem height. // As items are added or removed from the form item via ajax, the sizedPlaceholder // should grow or shrink accordingly. @@ -358,8 +361,6 @@ export class FieldPluginBase { }); Drupal.EditPlus.CurrentlyEditingElement.sizedPlaceholderHeightObserver.observe(formItem); - pageElement.classList.add('edit-plus-hidden'); - formItem.classList.add('edit-plus-editing'); formItem.classList.remove('edit-plus-hidden'); }