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

Determine why highlighting preview breaks #48

Open
cyrusae opened this issue Apr 20, 2022 · 1 comment
Open

Determine why highlighting preview breaks #48

cyrusae opened this issue Apr 20, 2022 · 1 comment
Assignees
Labels
bug Something isn't working frontend Involves /frontend help wanted Extra attention is needed Priority: ++++ High priority, other things cannot happen if this doesn't first UI Is the interface specifically

Comments

@cyrusae
Copy link
Owner

cyrusae commented Apr 20, 2022

Code:


 useEffect(() => {
  document.addEventListener('selectionchange', () => {
   let selection = document.getSelection().anchorNode.parentElement;
   if (selection != null) {
   if (selection.tagName ===  'mark') { 
    setPhrase(selection.innerText);
    if (code != null && code != '') {
     setPhrase('<mark class="' + code +  '">' + selection.innerText + '</mark>')
    }    
   } else {
    let sentence = document.getSelection().toString();
    setPhrase(sentence);
    if (code != null && code != '') {
     setPhrase('<mark class="' + code + '">' + sentence + '</mark>')
    }
   }
  }
   document.getElementById('phReview').innerHTML = phrase;
  })
 })

Issues:

  • Moving mouse causes page to crash because the parentElement is null.
  • Selecting multiple words ends at the second-to-last word.
  • Interaction with tooltips, and thus with highlights, extremely jank.
@cyrusae cyrusae added bug Something isn't working frontend Involves /frontend UI Is the interface specifically Priority: ++ Moderate priority, not dealbreaker OR mandatory but gated behind other things labels Apr 20, 2022
@cyrusae cyrusae self-assigned this Apr 20, 2022
@cyrusae
Copy link
Owner Author

cyrusae commented Apr 20, 2022

and (in [statementID].tsx)

document.addEventListener('selectionstart', () => {
     phrase.innerHTML = words;
     phrase.removeEventListener('pointerenter', () => {
      phrase.innerHTML += tooltip;
     });
    })

@cyrusae cyrusae added help wanted Extra attention is needed Priority: + Low priority, not urgent and removed Priority: ++ Moderate priority, not dealbreaker OR mandatory but gated behind other things labels Apr 21, 2022
@cyrusae cyrusae added Priority: +++ Basic functionality, I need this Priority: ++++ High priority, other things cannot happen if this doesn't first and removed Priority: + Low priority, not urgent Priority: +++ Basic functionality, I need this labels May 4, 2022
This was referenced May 4, 2022
@cyrusae cyrusae pinned this issue May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working frontend Involves /frontend help wanted Extra attention is needed Priority: ++++ High priority, other things cannot happen if this doesn't first UI Is the interface specifically
Projects
None yet
Development

No branches or pull requests

1 participant