Skip to content

Commit

Permalink
Fix a bug when expanding Expand will trigger auto cut (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
4vanger authored Aug 23, 2024
1 parent f6dc957 commit fe4b1c7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions frontend/src/Components/ContentComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function updateContent(
div: HTMLDivElement,
setZoomedImg: (img: ZoomedImg | null) => void,
setMailboxKey: (key: MailboxKey | MailKey | null) => void,
setCut: (cut: boolean) => void,
currentUsername?: string
) {
div.querySelectorAll('img').forEach(img => {
Expand All @@ -83,7 +84,7 @@ function updateContent(
});

div.querySelectorAll('details.expand').forEach(expand => {
updateExpand(expand as HTMLDetailsElement);
updateExpand(expand as HTMLDetailsElement, setCut);
});

div.querySelectorAll('span.secret-mailbox').forEach(mailbox => {
Expand Down Expand Up @@ -491,11 +492,12 @@ function updateSpoiler(spoiler: HTMLSpanElement) {
spoiler.addEventListener('click', spoilerOnClickHandler);
}

function updateExpand(expand: HTMLDetailsElement) {
function updateExpand(expand: HTMLDetailsElement, setCut: (cut: boolean) => void) {
expand.addEventListener('toggle', () => {
if (!expand.open) {
stopInnerVideos(expand);
}
setCut(false);
});

const expandClose = expand.querySelector('div[role="button"]');
Expand Down Expand Up @@ -569,7 +571,7 @@ export default function ContentComponent(props: ContentComponentProps) {
return;
}

updateContent(appState, content, setZoomedImg, setMailboxKey, props.currentUsername);
updateContent(appState, content, setZoomedImg, setMailboxKey, setCut, props.currentUsername);
let resizeObserver: ResizeObserver | null = null;

if (props.lowRating) {
Expand Down

0 comments on commit fe4b1c7

Please sign in to comment.