Scroll to Text Fragment - Gmail doesn't preview the link

49 views
Skip to first unread message

Michael Bradley

unread,
May 2, 2023, 8:02:54 PM5/2/23
to blink-dev
When drafting a gmail with a link containing a ScrollToTextFragmentDuties of Loyalty, Care and Obedience, clicking on the link (in Draft) shows the dialog, "Go to link: https ... | Change | Remove", but following the link to test my intention to scroll merely loads the target webpage.

However, sending the draft to a Yahoo email renders the highlighted text on the target webpage.  This is the desired result, but it would be more convenient to verify the intended behavior when testing the link in the draft.

Windows 10 Home 22H2 1/‎14/‎2021 Build: 19045.2846 
Chrome Version 112.0.5615.138 (Official Build) (64-bit)
GMail: 05-02-2023, No Add-ons, Advanced: all disabled.

I understand the desire to disable this behavior, but I appreciate what this feature can do, as demonstrated in this link.

PhistucK

unread,
May 8, 2023, 7:32:58 AM5/8/23
to Michael Bradley, blink-dev
Looks like the issue is that opening a URL with a scroll-to-fragment via window.open(...) does not scroll/highlight. GMail uses window.open(...) in draft mode.

Here is a small test case (copy it and paste it in the address bar and click on both of the links) -


There is also some weird handling of the fragment. If you unescape more than one of the commas (%2C), it stops highlighting -

Note that the URL you mentioned does not really have an accurate scroll-to-fragment, it uses %22 for all quotes, but the page uses special types of quotes (not sure why it works, but maybe there is some pre-processing for easier URL creation).


You can report this at crbug.com. Be sure to search for an existing issue first, though.



PhistucK


--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/2650c78e-e0f4-4d5d-9918-62a6ece72c1cn%40chromium.org.

David Bokan

unread,
May 9, 2023, 10:24:22 AM5/9/23
to blink-dev, PhistucK, blink-dev, Michael Bradley
Text fragments work just fine from `window.open` but have restrictions about being isolated from other pages. I suspect gmail isn't adding `noopener` in window.open so that the opened page remains reachable from gmail.

If that's the case, your link should work if you ctrl/cmd-click the link or right-click>"open in new tab".

PhistucK

unread,
May 9, 2023, 1:57:41 PM5/9/23
to David Bokan, blink-dev, Michael Bradley
That also does not work (in draft mode), but this is probably because it does not have an href (and it probably uses the same code path as a normal click), so a broken GMail implementation that breaks it.

PhistucK

David Bokan

unread,
May 9, 2023, 2:42:24 PM5/9/23
to PhistucK, blink-dev, Michael Bradley
Ah, I see it now...it's because GMail doesn't use an <a> tag...it fakes it and adds a click handler. Unfortunately there's not much you can do as a user in this case (aside from copy/pasting the URL manually) - ideally Gmail would fix their window.open to include noopener.

Michael Bradley

unread,
May 9, 2023, 7:39:15 PM5/9/23
to David Bokan, PhistucK, blink-dev
I agree that it would be good for Google to handle this the same way a copy&paste does.  Previewing/testing the link from GMail draft always opens another tab/window - at least in my experience - never a popup.

This was just a curiosity due to the inconvenience of NOT relying on the draft Preview/Test, but opening a window and copying the URL into it.

Hope you guys had fun with this.
Reply all
Reply to author
Forward
0 new messages