diff --git a/CHANGELOG.md b/CHANGELOG.md index 35c03fb3..a0fa37f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,13 +6,14 @@ and this project adheres to ## [Unreleased] -### Fixed - -- 🙈(docker) add \*\*/.next to .dockerignore #2034 - ### Changed - ♿️(frontend) ensure doc title is h1 for accessibility #2006 + +### Fixed + +- 🐛(frontend) fix image resizing when caption #2045 +- 🙈(docker) add **/.next to .dockerignore #2034 - ♿️(frontend) fix share modal heading hierarchy #2007 - ♿️(frontend) fix Copy link toast accessibility for screen readers #2029 diff --git a/src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-blocks/AccessibleImageBlock.tsx b/src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-blocks/AccessibleImageBlock.tsx index e43119e6..3410cc40 100644 --- a/src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-blocks/AccessibleImageBlock.tsx +++ b/src/frontend/apps/impress/src/features/docs/doc-editor/components/custom-blocks/AccessibleImageBlock.tsx @@ -57,30 +57,22 @@ export const accessibleImageRender = imgSelector?.removeAttribute('aria-hidden'); imgSelector?.setAttribute('tabindex', '0'); - const figureElement = document.createElement('figure'); + const originalCaption = dom.querySelector('.bn-file-caption'); - // Copy all attributes from the original div - figureElement.className = dom.className; - const styleAttr = dom.getAttribute('style'); - if (styleAttr) { - figureElement.setAttribute('style', styleAttr); - } - figureElement.style.setProperty('margin', '0'); + if (imgSelector?.parentNode && originalCaption) { + const figureElement = document.createElement('figure'); + figureElement.style.setProperty('margin', '0'); - Array.from(dom.children).forEach((child) => { - figureElement.appendChild(child.cloneNode(true)); - }); + // Wrap only the img inside figure, preserving the rest of the dom tree + imgSelector.parentNode.insertBefore(figureElement, imgSelector); + figureElement.appendChild(imgSelector); - // Replace the
caption with caption with