Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc fixes #724

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/components/Article/Contents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ const footnoteHTML = (el: HTMLDivElement, e: HTMLAnchorElement): string | null =
return elem.firstElementChild?.innerHTML || null
}

const addPopup = (e: HTMLElement, id: string, contents: string, mobile?: boolean): HTMLElement => {
const addPopup = (
e: HTMLElement,
id: string,
contents: string,
mobile: boolean = window?.innerWidth <= 780
): HTMLElement => {
const preexisting = document.getElementById(id)
if (preexisting) return preexisting

Expand All @@ -40,6 +45,7 @@ const addPopup = (e: HTMLElement, id: string, contents: string, mobile?: boolean
const toggle = () => popup.classList.toggle('shown')
popup.addEventListener('click', togglePopup(toggle, e))
e.addEventListener('click', togglePopup(toggle, e))
popup.children[0].addEventListener('click', (e) => e.stopPropagation())
}

return popup
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mruwnik, ok so there is a problem with multiple popups being added to a reference item for definitions. I think specifically, because the id is generated randomly, there can still exist two popups associated with the same reference whenever the function which creates the random ids is run more than once. And because react tends to just run things randomly...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried fixing this myself but I couldn't figure it out

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm. You're right :/ One way round this would be to pass in the id, rather than use a random one. So normal articles would just leave it empty, and chatbot ones would pass in their index in the history.

Otherwise the id would have to be generated based on the contents somehow, which would work for chat responses (as most of the time they will be unique), but not for articles in the chatbot (unless they have some magic token added secretly, which is also ugly). In this case the randomId would just be a hash of the html argument or something

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried again but I think this problem has far deeper and darker roots...
image
They are replicating inside each-other. Its like trying to fight hydra

Expand Down
9 changes: 7 additions & 2 deletions app/components/Article/article.css
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,14 @@ article .link-popup {
}

article .link-popup .footnote {
padding: var(--spacing-32) var(--spacing-32) 0 var(--spacing-32);
padding: var(--spacing-32) var(--spacing-32) var(--spacing-32) var(--spacing-32);
}

article .footnote-ref {
position: relative;
}

article .glossary-popup {
width: 522px;
height: 304px;
}

Expand Down Expand Up @@ -227,6 +226,12 @@ article .banner h3 .title {
flex-direction: column;
align-items: start;
}
article .link-popup .footnote {
margin-top: 42px;
}
article .glossary-popup {
margin-top: 50px;
}

article .link-popup {
width: 100%;
Expand Down
9 changes: 7 additions & 2 deletions app/components/Chatbot/chat_entry.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ article.stampy {
right: 0;
transform: translateX(50%);
visibility: hidden;
width: 256px;
max-width: 256px;
padding-top: 120%;
z-index: 100;
}
Expand All @@ -57,6 +57,8 @@ article.stampy {
color: white;
padding: var(--spacing-16);
border-radius: var(--border-radius);
width: max-content; /* Make the width adapt to its content */
max-width: 100%;
}

.chat-entry .hint-contents-container:hover,
Expand Down Expand Up @@ -197,10 +199,13 @@ article.stampy {
.reference-contents {
flex-shrink: 0;
width: 87.2vw;
margin-top: 48px;
margin-top: 46px;
}
.reference-popup {
display: flex;
flex-direction: column;
}
.chat-entry .hint-contents-container {
transform: translateX(10%);
}
}
3 changes: 0 additions & 3 deletions app/root.css
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,6 @@ svg {
/* mobile */

@media (max-width: 780px) {
body {
overflow-x: hidden;
}
.page-body {
padding: 0px var(--spacing-48);
}
Expand Down
Loading