Problem/Motivation
When drupal-media is embedded with data-caption="", opening the dialog and changing the alignment causes the edit button to disappear.
<drupal-media data-align="right" data-caption="" data-entity-type="media" data-entity-uuid="5cc07365-5fde-47a5-83b7-3302da0f0f2b" data-view-mode="wee"></drupal-media>
Video:
https://www.drupal.org/files/issues/2019-09-18/disappearing-edit-button.mov
The problem is that the code for the edit button blows up if the caption isn't properly initialized, due to this code:
// Find the actual embedded media in the DOM.
const embeddedMediaContainer = this.data.hasCaption
? this.element.findOne('figure')
: this.element;
Proposed resolution
Assure that if this.data.hasCaption
is true, that a figure actually exists.