Closed a-roussos closed 2 years ago
Hi @a-roussos :)! sorry for delay in response :/ (and please sorry about my english :/) I check the 2 alternatives and I think the best way to solve the problem is change the JS, because in the other way we need to anticipate the dom ID for all the
@a-roussos , if you agree, please go ahead with the PR :)
Fixed in 96e0805 with a small follow-up in 8153e2f. I'm closing this issue now 😄 Thanks for all your efforts, @tematres!
When viewing the details page of a term (e.g.
vocab/index.php?tema=123
) that has one or more narrower terms under it, TemaTres groups the blocks of narrower terms under HTML<ul>
tags. These are used when clicking on the blue arrow buttons next to a term, in order to expand or collapse the hierarchy.We recently came across a case where this does not work as intended.
When the same term appears more than once in the page, the aforementioned
<ul>
tags do not have unique identifiers (HTMLid
property) across the DOM. In such a scenario, only the first expand/collapse button (blue arrow) for the term that appears multiple times will operate normally; the remaining expand/collapse buttons (for the same term) will misbehave, since clicking on them causes the first instance of the term to expand/collapse. Here's a screen capture showing this in action (the problematic term is "theodicy"):To fix this issue, I modified the
HTMLverTE()
function so that the depth level of the current term ($i
) is appended to the term's id ($tema_id
):This resulted in
<ul>
identifiers that seemed unique, and for a moment I thought the issue was solved. However, I then realised that if the same term appears more than once under the same depth level, the<ul>
ids will not be unique and the problem re-appears. See, for example, what happens when I try to expand the second instance of the term "meditation":So, given that my initial approach was not working 100%, I reverted the changes I'd made in the
HTMLverTE()
function and decided to re-work the internals of the JavaScriptexpand()
function. Here's what I've come up with:This seems to have done the trick -- I can now expand and collapse the "theodicy" and "meditation" terms and it works fine.
I'm a bit hesitant to raise a PR, though, because in the long term my JS fix may not be enough (e.g. if the HTML layout of the details page changes in the future).
@tematres: I'd value your opinion on this! Do you think the JS fix is the best way forward? Do you have any ideas about how to produce 100% unique ids across the page?
Thank you! 👍