-
Notifications
You must be signed in to change notification settings - Fork 62
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
Highlight the anchor target #441
Conversation
I am fine with the general concept, but I find this styling unpleasant, especially without a way to clear it. Maybe just the background color, and fading out over a couple seconds? (I don't have much design background, alas.) |
@bakkot I don't have design credentials either, so this seems to be a matter of taste. Would you settle for just the background highlight without the fade out, and/or different styling for emu-xref vs. emu-clause (allowing reference highlighting to be cleared by navigating to its containing clause)? Either way, I'm happy to make style tweaks myself or to leave them to you. |
This will just show a highlighted background briefly: @keyframes highlight-target-bg {
0% {
background-color: rgba(249, 241, 172, 0)
}
20% {
background-color: rgba(249, 241, 172, 1);
}
100%{
background-color: rgba(249, 241, 172, 0)
}
}
:target {
animation: highlight-target-bg 1.5s cubic-bezier(0.22, 0.61, 0.36, 1);
} You can try it out by copy-pasting it into the We could also consider just doing |
Editors briefly chatted and all prefer the fade-out; Michael's snippet WFM. |
The workflow for which I care about this most is visiting references to an operation or definition, where the :target is therefore an <emu-xref> and I will frequently open many references in background tabs to visit in succession. Fading back to normal destroys that case because it will be done by the time I get there. What would you think about fading it for sectioning elements but leaving it on for <emu-xref>? |
I really don't like any option where the highlight persists, for any element. My usual working mode is clicking a reference and then scrolling around; having the highlight stay on page is quite distracting. For your workflow, would you be satisfied by some logic such that for pages which are not currently visible the highlight is persisted until 2 seconds after the page becomes visible? |
Unrelated to the above, I don't like that this highlights sections when clicking on links in the table of contents. Maybe exclude emu-clause and emu-annex? |
If the styling persists only on <emu-xref>, then a straightforward way to clear it would be navigating to the containing section already visible and distinguished in the menu pane. I already have local shortcuts for effectively this.
"satisfied" is a bit strong, but yeah, I can live with that.
I actually thought that was a bit of a feature for visually showing when a section with a short introduction has subsections, especially deep in the hierarchy where the font size of headings is similar (e.g., 10.1.5 [[GetOwnProperty]] or 20.1.2.3 Object.defineProperties). Is it the highlighting that you don't like, or how striking the background fade is? We could also use entirely different styling, e.g. a colored vertical bar on the side: |
I've updated the selector to exclude non-leaf clauses and annexes. Should just apply to |
@gibson042 I've added a subtle persistent highlight like you've suggested. Can you try it out and let me know what you think? |
@gibson042 I've split the persistent indicator into #552 as to not hold up the temporary highlight that seems generally acceptable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
split out persistent indicator to a separate PR
👍
It's having any visual change at all. To me the table of contents is a normal way of navigating within the document, and I don't expect things to visually change based on how I'm navigating within a document. That is, I expect the table of contents to work like it does on Wikipedia, MDN, or pretty much any other page; I don't want it to have any special effect on the document itself. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still adds highlights when navigating with the table of contents, which I'm not OK with.
Wouldn't it be more strange for the visual effects to vary based on how you got to an anchor, acting one way from the TOC but a different way based on links internal to the content? Also, although This really is the complement to highlighting the active section in the menu pane, which we've been doing for a long time. |
I agree it's a little strange, but certainly not more strange. Anyway, the thing I've actually proposed here is to not apply any styling to emu-clause or emu-annex, which are the only things in the table of contents, and that would mean that you get the same styling no matter how you navigate to an anchor. So no additional strangeness at all. So, the styling there is exactly what I want: a subtle highlight, applied only words or phrases rather than to clauses or headers (and, therefore, never when navigating from the ToC, since those things are not in the ToC), and fading out entirely after a couple seconds. Let's just do that (possibly with the addition of some logic to ensure the fade doesn't actually begin until the page is visible) instead of inventing something new. |
What about the new side indicator from #552? I can see shifting target section styling to only that, but without it we lose too much IMO.
The color fades out entirely, but the indication does not (at least on my machine) because the inline target is focused. So it actually has the persistence that I consider important in the form of a focus ring (but is trivially dismissable). |
That is the specific thing I most object to. I very specifically do not want any additional styling applied when navigating from the ToC, and I would prefer to not apply additional styling to targeted emu-clause or emu-annex elements regardless of how they are navigated to. No sidebar, no highlighting, nothing. We should behave like ~every other document instead of inventing something new.
Huh, I see that border on Chrome but not Firefox, and only when opening in a new tab rather than navigating within the same page (including refreshing). I'm not entirely sure how that works, but I would be fine with replicating that behavior as well. |
Hrm, I very specifically do want that styling, for visually indicating the scope of a target section and the location of its boundaries with neighboring sections (which are otherwise non-obvious in many places). Can you explain your objection beyond "most other pages don't have something similar"? Perhaps it's also worth us talking about synchronously in the next editor call. |
It's visually distracting; I don't like the content of the document to change out from under me when I'm navigating. (Imagine flipping through a book and colored ink appears and disappear on the pages - that would render the book unreadable.) Though also, "most other pages don't have something similar" seems like it ought to be sufficient on its own? Ubiquitous UI elements should work consistently across documents. Happy to chat synchronously though, fair warning, this opinion is very strongly held. We might be able to find something which satisfies us both but it's not going to look anything like the borders in that PR. |
I don't think that analogy holds up; this styling applies only when directly visiting a particular section rather than just wandering around... but to address it anyway, I would love for a book to highlight the specific relevant part of a page when I navigate from a TOC or glossary or just follow someone's reference to "page X, paragraph Y" or "§1.2.3" (just like a webpage or ebook does when searching).
ecmarkup has many novel affordances for common elements, such as (limiting to those that apply in main content rather than menu or references panes):
These are good things! And some of them are currently propagating throughout the ecosystem (the WHATWG specs in particular have basically the same alias highlighting and a similar contextual toolbox), just like dynamic TOC active-section highlighting already has. Our goal should not be "do what other pages do", but rather "do what is useful for readers [aligning with other pages where practical and avoiding gratuitous divergence]".
Acknowledged. |
Those are affordances for things particular to our document - very few webpages have anything like "spec aliases" or "algorithm steps", for example.
I regard "common UI elements behave the way they commonly do" as being useful for readers. When there's something which applies uniquely to our document, like spec aliases, that's a reasonable place to try to innovate. When it's something ubiquitous like a table of contents, that's a place to do what everyone else does. |
Very few documents are large like ours, or intended to support entry at arbitrary hyperlinked positions. I contend that this is a distinguishing aspect.
Now that's just hyperbolic. Adding a background or border is not meaningfully changing behavior any more than specifying a non-default cursor for <var> elements, and is arguably less of a behavior change than inserting hidden list counters. |
There are lots of long documents on the web with tables of contents? I am confused by the contention that this is at all unusual.
The behavior isn't having a background or border. It's making those change in response to clicking on an entry in the table of contents. I'm not objecting to the styling itself (well, also to that, but it's more likely we could find something mutually agreeable there) - I'm objecting to the styling changing when navigating with the table of contents. And that is, to me, a very meaningful (and very distracting) deviation from the common behavior for a table of contents. |
The table of contents itself exhibits the same highlighting behavior, and additionally expands and contracts in response to not just clicking but simply scrolling. The former behavior is not uncommon across the web today (although certainly far from universal, e.g. Wikipedia just added it this year), but it's still rather rare to encounter the latter. How is a static highlight that appears on navigation (i.e., an explicitly requested visual page jump) "very distracting" in the presence of such a dynamic table of contents? You said above that you are fine with the general concept, but have since introduced a new complaint related to the mode of navigation and are now escalating descriptions of distaste. I strongly value persistence and you strongly value dismissability; I think we can work that out but it now has its own PR #552. This PR introduces disappearing highlights on target references and leaf sections and non-leaf section headings, and I'd be comfortable with pretty much anything (or lack thereof) if there's a path to persistent highlighting (presumably dismissable, to satisfy you). So if you would agree to something persistent, then what tweaks would satisfy you here—and if you wouldn't, then what kind of disappearing highlights could you tolerate? |
I'm reporting my experience: I find the styling of the document changing as I use the table of contents to be distracting, and do not find the table of contents expanding distracting. Do you think I'm... mistaken about my experience? Do you think I have direct access to my brain's "what is distracting" algorithm? What would an answer to this question even look like? I mean, I can make guesses about the source of the difference - my best guess is that the relevant thing is that the highlight applies to the document, which is the thing I'm trying to look at - but I'm really just reporting the fact of my experience here.
When I said that I was fine with the general concept I'd only looked at navigating from the references pane. It didn't occur to me that it also applied to the table of contents; as soon as I noticed that I said I didn't like it. You asked about why I cared and in response I've tried to explain why I cared: it's only "escalating descriptions of distaste" because you explicitly asked me to explain my objection. I didn't immediately jump to "descriptions of distaste" because "I don't like this" usually suffices.
Like I said:
That is, exactly what the WHATWG specs are doing (plus optionally the page visibility thing). I don't like the original styling but if you really want something other than just background color we could probably find something else which works. Doing just background color (with the above constraints) would satisfy me though. I really doubt I'm going to be ok with any option which includes changing the styling of the main document when using the table of contents, whether or not it's persistent. You can suggest such options but I at least can't think of any which I'd be ok with. Like I said, I'm happy to chat sync at the editor call if you'd like. |
Well, yes? For example, I'm distracted by the toolbox popup appearing on hover and covering other text. As for this question, I can think of several kinds of answer:
I am very much in favor of something persistent w.r.t. sections and independent of navigation mode, so I'll try to join the next call. |
"I'm distracted by this common UI element having more visual effects on the thing I'm trying to look at than what I was expecting, based on how said element typically behaves elsewhere" is the best answer I can give you. I don't think it bottoms out in some other reason - the chain of "I find X distracting because it entails Y, which I find distracting [because...]" has to stop somewhere, and as far as I can tell that's where it stops. |
I've updated this PR to hopefully remove the controversial aspects. It now skips the highlight for clause-like elements, makes the highlight persistent when the target has focus and is "simple" (has either no children or only <a> children), and adds |
Thanks, this works for me now, modulo technical quibbles. First, apparently (that is, it appears to me) elements only get Second, the behavior when using output.mp4 |
Right, that's a concession on my part. I'm comfortable with opting in to xref persistence by hitting tab, and <dfn>s that lack IDs are effectively aliases for their containing clauses w.r.t. references and therefore won't get highlighted.
Addressed that by adjusting the animation to remove the initial ramp up; tabbing away will now fade out just like happens in the absence of initial focus. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WFM but will hold off on merging until at least one more editor has had a chance to weigh in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is better than not doing anything, but I still strongly prefer indicating in some way when navigating to a section, such as highlighting the header, as we had it before.
I think highlighting the anchor target would help readability, especially for refs. Specific colors and styles could obviously be tweaked, though.
Preview (ref)
Preview (section)