haskell / haddock

Haskell Documentation Tool
www.haskell.org/haddock/
BSD 2-Clause "Simplified" License
361 stars 241 forks source link

Selecting a line of a function/data type without a signature will select `source` as well #1252

Open KommuSoft opened 3 years ago

KommuSoft commented 3 years ago

If one uses a browser to look at the rendered page, and double clicks on an element without a signature, then it also selects the Source element at the right. For example, if one double clicks on calendarListPatch, then Source is also added. This is inconvenient since if one copies the identifier, then it also copies Source at the end, and thus the copied part is calendarListPatchSource, instead of calendarListPatch.

For elements with a signature in the same element, this is not the case, indeed, if one double clicks on clpCalendarId, it only selects clpCalendarId.

alexbiehl-gc commented 3 years ago

I too found this very annoying. I have no clue how to fix this reliably though. Do you have an idea?

vdukhovni commented 3 years ago

I tried this in Chrome, Firefox and Safari. Only Chrome exhibits the issue. Perhaps this is more of a Chrome bug than a haddock issue? FWIW, dragging across the word left to right does not select "Source" if one stops exactly on the last letter, but of course this is more effort than a double-click...

KommuSoft commented 3 years ago

I tried this in Chrome, Firefox and Safari. Only Chrome exhibits the issue. Perhaps this is more of a Chrome bug than a haddock issue?

Yes, although I'm not sure it is a "bug". Are there any specifications how about the boundaries when selecting a word/sentence? Perhaps we could look how we can make the boundaries more "robust".

harpocrates commented 3 years ago

Hmmm... I wonder if we could have some place that could be clicked on to "copy to clipboard" the identifier (maybe the ::, but then again I was thinking that would someday be a great place to toggle type variables and their kinds...). Otherwise, I bet we could also fix this by changing the HTML structure generated just slightly.

Vekkq commented 3 years ago

Seems that Chromium ignores the delimiter space between a function name and Source, because Source and # are floating. This causes Chromium to assume, that it is a single word.

Workaround: triple click the function name. That somehow works.

As to fix it, one could try

  1. Replace floating CSS with something more sensible for element placement. Maybe Flexbox.
  2. Separate elements by divs that float for them instead.
  3. Add a non-space delimiter between the function name and Source. Can be an invisible delimiter or simply switching the self-ref # around Source.

Last one should be the easiest solution and one would only have to add <span style="opacity:0">*</span> or so.