Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Fix partial clipped lines showing through on the caption

Manav Rathicfe6343d63e6
diff --git a/web/apps/photos/src/styles/photoswipe.css b/web/apps/photos/src/styles/photoswipe.css
index dd072cc580..cdc709c6d7 100644
--- a/web/apps/photos/src/styles/photoswipe.css
+++ b/web/apps/photos/src/styles/photoswipe.css
@@ -155,23 +155,24 @@
bottom: 0px;
right: 0;
margin: 20px 24px;
- padding: 8px 16px;
+ padding-inline: 16px;
border-radius: 3px;
/* Same opacity as the other controls. */
color: rgb(255 255 255 / 0.85);
background-color: rgb(0 0 0 / 0.2);
backdrop-filter: blur(10px);
- /* 4 lines max, ellipsis on overflow. */
- word-break: break-word;
text-align: right;
max-width: 375px;
max-height: 200px;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-line-clamp: 4;
- line-clamp: 4;
+ p {
+ /* 4 lines max, ellipsis on overflow. */
+ word-break: break-word;
+ overflow: hidden;
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 4;
+ line-clamp: 4;
+ }
}
/* Change the cursor on the thumbnail to the default arrow to indicate that it is
diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.ts
index 4bfae068b0..39cb87e085 100644
--- a/web/packages/gallery/components/viewer/photoswipe.ts
+++ b/web/packages/gallery/components/viewer/photoswipe.ts
@@ -930,12 +930,19 @@ export class FileViewerPhotoSwipe {
// them (nb: the caption will hide when the video is playing).
order: 31,
appendTo: "root",
- tagName: "p",
+ // The caption uses the line-clamp CSS property, which behaves
+ // unexpectedly when we also assign padding to the "p" element
+ // on which we're setting the line clamp: the "clipped" lines
+ // show through in the padding area.
+ //
+ // As a workaround, wrap the p in a div. Set the line-clamp on
+ // the p, and the padding on the div.
+ html: "<div><p></p></div>",
onInit: (element, pswp) => {
captionElement = element;
pswp.on("change", () => {
const { fileType, alt } = currSlideData();
- element.innerText = alt ?? "";
+ element.querySelector("p")!.innerText = alt ?? "";
element.style.visibility = alt ? "visible" : "hidden";
// Add extra offset for video captions so that they do
// not overlap with the video controls. The constant is