Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embedded Document Links don't correctly display Caption #985

Open
alan-cole opened this issue Jul 1, 2021 · 0 comments
Open

Embedded Document Links don't correctly display Caption #985

alan-cole opened this issue Jul 1, 2021 · 0 comments

Comments

@alan-cole
Copy link
Collaborator

alan-cole commented Jul 1, 2021

Describe the bug
When creating a basic text field on a landing page, and adding Media embed of type Document, If a caption is included with the embed, The end-result on the page will display an indented document link, with a caption that is not using the Document Link's caption style.

To Reproduce
Steps to reproduce the behaviour:

  1. Create a new Landing Page
  2. Add a Basic Text WYSIWYG
  3. Add a Media embed for a document with a caption
  4. Complete creating the landing page and save
  5. View the page on the front-end
  6. Observe the indented / incorrectly styled caption.

Expected behaviour
A Document Link caption should render as per the Document Link component.
https://www.ripple.sdp.vic.gov.au/?path=/story/molecules-documentlink--document-link
Screen Shot 2021-07-01 at 12 04 33 pm

Actual behaviour
The document link is appearing indented, with a differently styled caption text.
Screen Shot 2021-07-01 at 12 12 49 pm

Screenshots
This is using the caption field provided by Drupal media embed:
Screen Shot 2021-07-01 at 12 08 06 pm

Versions

  • Ripple: 1.22.0

Desktop (please complete the following information):

  • OS: macOS
  • Browser Firefox / Chrome
  • Version: Latest

Additional context
From what I can see of the HTML:

An expected document link should output like:

<figure class="rpl-document-link">
  <a aria-label="This is the name of the document File type: pdf. Size: 1.4 mb" href="https://www.google.com" target="_blank" class="rpl-document-link__link">
    <!-- <svg>Removed embedded svg for clarity</svg> -->
    <div class="rpl-document-link__info">
      <span class="rpl-document-link__title">This is the name of the document</span>
      <div class="rpl-document-link__meta">
        <span class="rpl-document-link__type">pdf</span><span class="rpl-document-link__size rpl-document-link__size--seperator">1.4 mb</span>
      </div>
    </div>
  </a>
  <figcaption class="rpl-document-link__caption">This is a longer description of the document above.</figcaption>
</figure>

But what is being output by the Markup component is:

<figure role="group" class="caption caption-drupal-entity">
  <figure class="rpl-document-link">
    <a aria-label="Demo Sample Document File type: docx. Size: 7.53 KB" href="/sites/default/files/tide_demo_content/sample.docx" download="" class="rpl-document-link__link">
      <!-- <svg>Removed embedded svg for clarity</svg> -->
      <div class="rpl-document-link__info">
        <span class="rpl-document-link__title">Demo Sample Document</span>
        <div class="rpl-document-link__meta">
          <span class="rpl-document-link__type">docx</span> <span class="rpl-document-link__size rpl-document-link__size--seperator">7.53 KB</span>
        </div>
      </div>
    </a>
    <!---->
  </figure>
  <figcaption>This is a caption!</figcaption>
</figure>

Where a figure with a figcaption is wrapping the document link figure.

I believe this is because the markup-plugin that swaps out the Drupal embed with the Vue component doesn't check if it's being wrapped by a figure with caption.

If the markup plugin could also check for any document embeds within a figure, then replace the figure with the document link (with caption passed to the document link component), this should fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant