From 177fc0f9ad2cce8dbb7096f90178e640233d419c Mon Sep 17 00:00:00 2001
From: Takashi Kato <tohosaku@cosmichorror.org>
Date: Fri, 17 Apr 2026 00:42:59 +0000
Subject: [PATCH 3/3] Use stylesheet instead of JavaScript

---
 app/assets/javascripts/application-legacy.js | 20 --------------------
 app/assets/stylesheets/application.css       |  6 ++++++
 2 files changed, 6 insertions(+), 20 deletions(-)

diff --git a/app/assets/javascripts/application-legacy.js b/app/assets/javascripts/application-legacy.js
index 531a6f6e0a7..9fa335f1409 100644
--- a/app/assets/javascripts/application-legacy.js
+++ b/app/assets/javascripts/application-legacy.js
@@ -1211,25 +1211,6 @@ $(function ($) {
   }).change();
 });
 
-function setFilecontentContainerHeight() {
-  var $filecontainer = $('.filecontent-container');
-  var fileTypeSelectors = ['.image', 'video'];
-
-  if($filecontainer.length > 0 && $filecontainer.find(fileTypeSelectors.join(',')).length === 1) {
-    var containerOffsetTop = $filecontainer.offset().top;
-    var containerMarginBottom = parseInt($filecontainer.css('marginBottom'));
-    var paginationHeight = $filecontainer.next('.pagination').height();
-    var diff = containerOffsetTop + containerMarginBottom + paginationHeight;
-
-    $filecontainer.css('height', 'calc(100vh - ' + diff + 'px)')
-  }
-}
-
-function setupAttachmentDetail() {
-  setFilecontentContainerHeight();
-  $(window).resize(setFilecontentContainerHeight);
-}
-
 function setupWikiTableSortableHeader() {
   if (typeof Tablesort === 'undefined') { return; }
   $('div.wiki table').each(function(i, table){
@@ -1454,7 +1435,6 @@ $(document).ready(setupAjaxIndicator);
 $(document).ready(hideOnLoad);
 $(document).ready(addFormObserversForDoubleSubmit);
 $(document).ready(defaultFocus);
-$(document).ready(setupAttachmentDetail);
 $(document).ready(setupFilePreviewNavigation);
 $(document).on('focus', '[data-auto-complete=true]', function(event) {
   inlineAutoComplete(event.target);
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
index b31775fda0e..c2967acdbc4 100644
--- a/app/assets/stylesheets/application.css
+++ b/app/assets/stylesheets/application.css
@@ -2530,10 +2530,16 @@ img {
   image-orientation: from-image;
 }
 
+div#content:has(.filecontent-container) {
+  display: flex;
+  flex-direction: column;
+}
+
 .filecontent-container {
   position: relative;
   margin-block-end: 20px;
   min-block-size: 200px;
+  flex-grow: 1
 }
 .filecontent-container > .filecontent {
   position: absolute;
-- 
2.47.3

