Compare commits

...

2 Commits

Author SHA1 Message Date
Matthias Portzel 6408c3db55 Fix bug that prevented editing alt-text
* If there was already an uploaded file, it doesn't get re-uploaded when editing, and doesn't show up in request.FILES. The file name is still in thought.media so we can use that to tell if there's a image and if we should allow media_alt
2022-03-29 13:27:49 -04:00
Matthias Portzel 4c2251a460 Save and restore scroll position
* This is a big deal when typing thoughts that are over a page long, it will jump you to the bottom of the input box every time and it's a little jarring.
2022-03-28 23:45:18 -04:00
2 changed files with 7 additions and 3 deletions

View File

@ -40,11 +40,15 @@
const textExtEl = document.getElementById("id_extended_text");
function updateBoxHeight(box) {
// Save scroll position
const scrollY = window.scrollY;
//style.height doesn't include padding, .scrollHeight does
box.style.height = "auto";
// Set overflow hidden to ensure scrollbars aren't shown, since they change the width and thus the height
box.style.overflow = "hidden";
box.style.height = box.scrollHeight + "px";
//Restore scroll position
window.scrollTo(0, scrollY);
}
// If we're handling maxlength in JS, then having the maxlength attribute is annoying
@ -84,7 +88,6 @@
}
});
const mediaInput = document.getElementById("id_media");
const mediaAlt = document.getElementById("id_media_alt");
const clearCheckbox = document.getElementById("media-clear_id");

View File

@ -143,8 +143,9 @@ def post(request):
], check=True)
os.remove(os.path.join(settings.MEDIA_ROOT, f"{thought.uuid}.m4a")) # Remove the original file
thought.media.name = f"{thought.uuid}.aac" # Update the file in the DB
else:
# We need to make sure that if we remove an image, the alt text is removed with it
# We need to make sure that if we remove an image, the alt text is removed with it
if not thought.media:
thought.media_alt = ""
# Save for real