Skip to content

Commit

Permalink
fix: image captions (#986)
Browse files Browse the repository at this point in the history
[![PR App][icn]][demo] | Ref RM-10929
:-------------------:|:----------:

## 🧰 Changes

Fixes rendering some captions.

It's super unclear to me why sometimes the image saves the caption as
children and sometimes as a prop. But it wasn't rendering the children!

## 🧬 QA & Testing

- [Broken on production][prod].
- [Working in this PR app][demo].


[demo]: https://markdown-pr-PR_NUMBER.herokuapp.com
[prod]: https://SUBDOMAIN.readme.io
[icn]:
https://user-images.githubusercontent.com/886627/160426047-1bee9488-305a-4145-bb2b-09d8b757d38a.svg
  • Loading branch information
kellyjosephprice authored Oct 3, 2024
1 parent 90bf6e6 commit 0db3627
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions __tests__/browser/markdown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('visual regression tests', () => {
//'features',
'headings',
'images',
'imageTests',
'lists',
'mdxComponents',
'tables',
Expand Down
2 changes: 1 addition & 1 deletion components/Image/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const Image = (Props: ImageProps) => {
setLightbox(!lightbox);
};

if (caption) {
if (children || caption) {
return (
<figure>
<span
Expand Down
35 changes: 35 additions & 0 deletions docs/image-tests.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
We're excited you're here! :blue_heart:

<Image src="https://owlbertsio-resized.s3.amazonaws.com/Blocks.psd.full.png">
Owlbert!
</Image>

<Table align={["left","left","left"]}>
<thead>
<tr>
<th style={{ textAlign: "left" }} />

<th style={{ textAlign: "left" }} />

<th style={{ textAlign: "left" }} />
</tr>
</thead>

<tbody>
<tr>
<td style={{ textAlign: "left" }} />

<td style={{ textAlign: "left" }} />

<td style={{ textAlign: "left" }} />
</tr>

<tr>
<td style={{ textAlign: "left" }} />

<td style={{ textAlign: "left" }} />

<td style={{ textAlign: "left" }} />
</tr>
</tbody>
</Table>
3 changes: 3 additions & 0 deletions example/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import headings from '../docs/headings.md';
// @ts-ignore
import images from '../docs/images.md';
// @ts-ignore
import imageTests from '../docs/image-tests.mdx';
// @ts-ignore
import lists from '../docs/lists.md';
// @ts-ignore
import mdxComponents from '../docs/mdx-components.mdx';
Expand All @@ -42,6 +44,7 @@ const fixtures = Object.entries({
gettingStarted,
headings,
images,
imageTests,
lists,
mdxComponents,
sanitizingTests,
Expand Down

0 comments on commit 0db3627

Please sign in to comment.