WICG / scroll-to-text-fragment

Proposal to allow specifying a text snippet in a URL fragment
Other
589 stars 42 forks source link

Scroll without having to right click and select "Remove highlight" everytime #199

Closed Jonnas123 closed 10 months ago

Jonnas123 commented 1 year ago

I have one page scroll and a list of text fragment links on a sidebar. But I have to right click and select "Remove highlight" everytime before jumping to other text fragment links otherwise it's not working properly. Is it possible to scroll without having to remove highlight evertime? rm

bokand commented 1 year ago

Hi, sorry for the delay.

When you say "it's not working properly", could you elaborate on what you expect to happen?

When I try this on my test page clicking on each link scrolls to the text as expected without having to remove highlights.

The old highlight isn't removed, is that what you mean? (i.e. that navigating to a new text fragment should remove any existing highlights?)

Jonnas123 commented 1 year ago

I save long highlight texts on my page, so when I open one by one on the same page, the old existing highlight texts are mixed together, making it's not scrollable. So that's why I understand it's not working properly. So my point is like you said "The old highlight isn't removed, is that what you mean? (i.e. that navigating to a new text fragment should remove any existing highlights?)" Is it possible to remove any existing highlight text when navigating to a new text fragment?

bokand commented 1 year ago

the old existing highlight texts are mixed together, making it's not scrollable

Still want to clarify on this point - a new highlight and scroll should still happen, even if the old text highlight isn't removed. Is that the case?

Is it possible to remove any existing highlight text when navigating to a new text fragment?

It's not today but it seems like reasonable behavior to me that if a new text directive is set the old highlights get cleared. I'll have to consider how this could work w.r.t. the processing model.

Jonnas123 commented 1 year ago

Still want to clarify on this point - a new highlight and scroll should still happen, even if the old text highlight isn't removed. Is that the case?

Sorry for not being clear enough. I casually saw the issue. From now I'll try to be specific. And here is some reports from me:

  1. For example, I have the following lines of text.

LINE1 LINE2 LINE3 LINE4 LINE5

I highlight LINE1 - LINE3 as one link and LINE3 - LINE5 as the other link and then open the links one by one respectively on the same page, the result is that the LINE3 - LINE 5 is not highlighted.

  1. I place a link in Bootsrap offcanvas and when I click on it, the offcanvas is closed and opens up the page but not scroll to the point. This happens in mobile chrome browser.

  2. Regarding the other "scroll" issue, previously I casually notice that somehow it's not scrolling but don't remember, so cann't reproduce the issue. Next time, I'll try to remember and be specific.

  3. And in desktop some texts cannot be copied as the "copy link to hilighlight" is grey out. Some text can be copied in desktop browser but not in mobile browser.

It's not today but it seems like reasonable behavior to me that if a new text directive is set the old highlights get cleared. I'll have to consider how this could work w.r.t. the processing model.

For example, I have the following lines of text

LINE1 LINE2 LINE3

First I copy LINE1 - LINE3 as one link and just only LINE 2 in the middle as the other link. Then open the links one by one respectively on the same page. My question is how do you see the highlight of LINE2 as it's mixed with the old highlight (LINE1 - LINE3) without removed? To me, the old highlight should have been removed automatically when navigating to a new one, giving an accurate preview of current highlight.

bokand commented 1 year ago

I highlight LINE1 - LINE3 as one link and LINE3 - LINE5 as the other link and then open the links one by one respectively on the same page, the result is that the LINE3 - LINE 5 is not highlighted.

Yeah, this is a known limitation on overlapping highlights in Chrome - https://crbug.com/1327370

  1. I place a link in Bootsrap offcanvas and when I click on it, the offcanvas is closed and opens up the page but not scroll to the point. This happens in mobile chrome browser.

  2. Regarding the other "scroll" issue, previously I casually notice that somehow it's not scrolling but don't remember, so cann't reproduce the issue. Next time, I'll try to remember and be specific.

  3. And in desktop some texts cannot be copied as the "copy link to hilighlight" is grey out. Some text can be copied in desktop browser but not in mobile browser.

There are some cases that cause text fragments to break (e.g. page script resetting the scroll offset, content loading via script). Differences in pages pages between mobile and desktop can also affect how text fragments are generated/matched.

That said, I'm happy to take a look if you find specific examples. Feel free to file bugs with links at https://crbug.com/new

First I copy LINE1 - LINE3 as one link and just only LINE 2 in the middle as the other link. Then open the links one by one respectively on the same page. My question is how do you see the highlight of LINE2 as it's mixed with the old highlight (LINE1 - LINE3) without removed? To me, the old highlight should have been removed automatically when navigating to a new one, giving an accurate preview of current highlight.

Yep, this is the overlapping range problem I mentioned above. Indeed, removing the highlight on a new navigation would solve it in this case (though you can still create a link with multiple highlights by adding &text= terms).

bokand commented 10 months ago

Closing out old issues. It seems there isn't anything actionable here. Feel free to file a new issue if that's not the case.