On Fri, 20 May 2022 18:42:57 GMT, Jorn Vernee <jver...@openjdk.org> wrote:

>> This is a CSS/JavaScript only change to implement copy-to-clipboard 
>> functionality for all headers (`h1` - `h6`) that have an `id` attribute 
>> associated with them. The following element-attribute patterns are supported 
>> (using `<h2>` as an example):
>> 
>>  - `<section id="..."><h2>` (generated by javadoc)
>>  - `<h2 id="...">` (commonly used)
>>  - `<h2><a id="...">` (legacy)
>> 
>> The change includes a consolidation of the CSS styles used to render 
>> copy-to-clipboard buttons, of which we have now three kinds: for snippets, 
>> for the link on the search page, and for headers. There is now a base CSS 
>> class called "copy" that defines the styles shared by all copy-to-clipboard 
>> buttons, and additional CSS properties for the concrete "subclasses". 
>> 
>> API docs generated with this change can be viewed here (top level files and 
>> java.base module):
>> http://cr.openjdk.java.net/~hannesw/8277420/api.02/
>
> It seems to work in other cases, like here: 
> http://cr.openjdk.java.net/~hannesw/8277420/api.02/java.base/java/lang/foreign/Linker.html
>  (e.g. the "Downcall method handles" section)
> 
> Where the text is contained within the `<a>` tag.
> 
> ---
> 
> Also, I notice that the button only appears after hovering over the text of 
> the heading in the case above, but not when just hovering over the place 
> where the button would appear itself (and not touching the text). The hover 
> area feels a bit small. Would it be possible to make the area bigger? For 
> instance, the entire width of the page at the height of the header? For 
> methods this already seems to be the case as well.

Thanks for the valuable feedback, @JornVernee! It turns out that both problems 
you observed (empty `<a id=...` not working at all and other "legacy" headers 
only showing the icon when hovering over the text) had the same cause, which 
was that the hover event handler was registered on the `<a>` element instead of 
the header. 

I've added a fix for this, you can test it here:
http://cr.openjdk.java.net/~hannesw/8277420/api.03/java.base/java/lang/invoke/MethodHandle.html#sigpoly

Regarding the size of the icon/button, it's true that it's on the smaller side. 
The reason is that I tried to fit it into the line size of the header both for 
visual and technical reasons (easier to size using relative rather than 
absolute measures). If it was any bigger, the header line height would increase 
when hovering over it. If it turns out that more people find it too small we 
can increase the size with a bit more work (absolute positioning and sizing).

-------------

PR: https://git.openjdk.java.net/jdk/pull/8817

Reply via email to