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

Tooltips plugin malfunctions when citation hidden in <details> #268

Closed
dhimmel opened this issue Sep 13, 2019 · 4 comments · Fixed by #409
Closed

Tooltips plugin malfunctions when citation hidden in <details> #268

dhimmel opened this issue Sep 13, 2019 · 4 comments · Fixed by #409
Labels
frontend issues related to the HTML view and interactivity

Comments

@dhimmel
Copy link
Member

dhimmel commented Sep 13, 2019

@humbertodebat is leading a cool project to translate the Sci-Hub Coverage Study manuscript to spanish. We are keeping the English text but using the HTML <details> element to collapse it by default. See manuscript here:

image

For future reference, we made some changes to the CSS to style the details in greenelab/scihub-manuscript-es@56313e8 and greenelab/scihub-manuscript-es@3a667f2.

Because we keep the english original in <details> (collapsed by default), each citation appears double. When using the tooltip extension to jump between other instances of the same citation, the tooltip goes away. @vincerubinetti is there a more natural way the extension could handle this?

@vincerubinetti
Copy link
Collaborator

vincerubinetti commented Sep 13, 2019

You are referring to when you open a tooltip, then navigate to a prev/next instance of the same citation, and that next/prev citation happens to be inside a collapsed section.

There is no natural way to handle this. The tooltips plugin has to be updated to expand or show any hidden element it is focusing.

The relevant code is here:

function goToElement(element, offset) {
// expand accordion section if collapsed
expandElement(element);
const y =
getRectInView(element).top -
getRectInView(document.documentElement).top -
(offset || 0);
// trigger any function listening for "onscroll" event
window.dispatchEvent(new Event('scroll'));
window.scrollTo(0, y);
document.activeElement.blur();
element.focus();
}

Note how it has to check if the new link it is focusing is within an accordion section, and expand it manually if it is.

@dhimmel
Copy link
Member Author

dhimmel commented Sep 13, 2019

Do either of these solutons make sense:

  1. expand <details> like how an accordion is expanded when the next instance is contained in this section

  2. skip over instances that cannot be expanded. for example, this could go from citation 1/4 to 3/4 because 2/4 was in collapsed details.

Both solutions would keep the tooltip active. The disappearance of the tooltip is the main issues IMO with the current situation.

@vincerubinetti
Copy link
Collaborator

Depends on the functionality you want. Either way, we should make it consistent for both accordion sections and details sections. Either expand on navigate or skip.

@dhimmel
Copy link
Member Author

dhimmel commented Sep 13, 2019

we should make it consistent for both accordion sections and details sections. Either expand on navigate or skip.

expand on navigate seems like the best solution, since users often use the next button to browse every instance of a citation.

@dhimmel dhimmel added the frontend issues related to the HTML view and interactivity label Mar 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
frontend issues related to the HTML view and interactivity
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants