-
Notifications
You must be signed in to change notification settings - Fork 508
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
Add more descriptive tooltip for <= versions #2966
Conversation
@cincodenada You did all of that using the GitHub UI?! Cool. @ddbeck or @Elchi3 Can you provide some early/quick feedback to @cincodenada about the underlying feature here? If it helps, I can vet the code and perhaps run it to present some screenshots for an easier discussion. |
@peterbe The first commit was all in the web IDE yeah! It's pretty slick these days. When the linter checks failed I did get it checked out locally so I could run I just checked out the README and it was impressively easy to get up and running, I went ahead and did so, so here's before/after screenshots of |
As for mobile tooltips, I know there are various ways to support tooltips on mobile but am not really familiar with them beyond that, and there may be an established way in this or other MDN projects. An alternate solution would be to use something like footnotes, at least for more complicated situations like the <= case. Also, I'm not committed to any specific wording here, happy to hear feedback there - for instance, I like "Specific version unknown" but I could see it being more verbose than necessary. (Edit: I went ahead and just changed "Exact" to "Specific", along with some small code tweaks) |
I didn't understand how it worked at first, and in fact got an incorrect idea of how the <= worked from reading the tooltips, which is why I'm here :) I got some very helpful explanation from some folks from commenting on the browser-compat-data PR that introduced the <= version that I saw, which is how I understand now, it may be helpful context: mdn/browser-compat-data#4637 Of particular note is the "Ranged versions" section of the docs linked above, which explains specifically what <= means: https://github.com/mdn/browser-compat-data/blob/master/schemas/compat-data-schema.md#ranged-versions |
I am not at all criticizing browsers-compact-data here - in fact, my assertion is that as-is the chart is misrepresenting the data they provide. For instance, for both The existing code is already calculating that sentence for the tooltip - this PR is just changing the sentence to more accurately reflect the data provided by browsers-compat. And we already take into account all the items in And in any case, the issue at hand is that the sentence we calculate for a specific type of added/removed version (the <= version) doesn't fully describe the meaning that browsers-compat specifies for it, and can be easily misinterpreted so as to not represent the intent of browsers-compat. This PR updates how we calculate the sentence to better reflect the intent of browsers-compat. |
@cincodenada #2705 is talking about accessible tooltips, so don't worry about it right now. |
@Ryuno-Ki Oh, excellent, thanks for the tip! I am also interested in improving tooltips separately, so I appreciate the link :) |
I'm fine with this approach to the title text, though I have a small suggestion for the phrasing (though I'm not sure how best to implement it). In the screenshot, the final string in the ranged case is: "Specific version unknown: supported ending in version 37 or earlier." That "supported" makes it a little bit awkward to read. "Specific version unknown: support ended in version 37 or earlier." flows a little better. Alternatively—since there many entries that use this notation—it might be better to put the more specific details first and put the general caveat last. Something like, "Support ended in version 37 or earlier (specific version unknown)" |
By the way, @cincodenada thanks for taking an interest in this. Glad my explanation in the compat repo was helpful! |
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.
@cincodenada If you can heed Daniel's suggestions I'm ready willing and able to merge this. Great work! We need more people like you.
Great, thanks for all the feedback! I've updated the wording per @ddbeck's suggestions, which I think are all good improvements. All good to merge from my end. One final bit of bikeshedding I realized: with the new wording, we could also just use browser-compat-data's wording directly and say "Support added"/"Support removed" (vs started/ended). If that seems markedly better I can make that change as well. |
Great! I don't think we need to exactly follow the wording from BCD. Maybe continue with the wording you've got here and revisit it if there's confusion about the tooltip text? @peterbe I'm happy with this, but I'll leave actual code review to you. |
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.
The use of a string as a form of "enum" is a bit strange when there's only ever two possible states. Can you change the signature to:
function labelFromString(
version: string | boolean | null | undefined,
added: bool
)
And where you call it, change according to: labelFromString(added, true)
or labelFromString(removed, false)
.
What's cool about TypeScript is that it you give you a nice tooltip in your IDE when you hover over the labelFromString
and then it's not so weird to know/see/remember what that second boolean is for.
Another syntax which is quite nice would be something like this:
function labelFromString(
removed?: string | boolean | null | undefined,
added?: string | boolean | null | undefined,
)
then you can use it like this, for example:
labelFromString({ removed })
and within the function you'd be able to tell which description to use based on the argument used.
For I think the first suggestion is simpler and more appropriate. A bool instead of a string enum.
I had considered the boolean option, so I'm happy to go with that - I took a slightly different tack and made it an optional boolean, essentially defaulting to the added case, since removed is the minority/exceptional case. That said, if there's a preference for explicitly including the second argument in both cases, I'm fine with going that way as well. The property shorthand idea is quite clever indeed, and rather elegant! I also agree it may be just a bit too clever, as much as I love it, and the simpler boolean is the most accessible option 😄 |
@cincodenada Same problem here. I can't seem to override the fact that your commits aren't signed. Do you mind rebasing your branch locally so all commits are signed? |
The existing tooltip can easily be read as implying the feature is only supported in the given range, rather than support starting in that range. It's doubly confusing when the removed version is <=, because then the tooltip is written primarily for the added case.
Before: "Specific version unknown: supported ending in version 37 or earlier." After: "Support ended in version 37 or earlier (specific version unknown)"
Just use a boolean, keep things simple
Okay, as on #2995 , finally got around to this and rebased/squashed a bit while I was at it. Let me know if there's any remaining feedback, thanks! |
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.
Some nits (but there would be merge conflicts anyway).
@@ -101,14 +101,19 @@ function NonBreakingSpace() { | |||
return <>{"\u00A0"}</>; | |||
} | |||
|
|||
function labelFromString(version: string | boolean | null | undefined) { | |||
function labelFromString( | |||
version: string | boolean | null | undefined, |
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.
Is there a difference between the above and
version: string | boolean | null | undefined, | |
version?: string | boolean | null, |
?
if (typeof version !== "string") { | ||
return <>{"?"}</>; | ||
} | ||
if (!version.startsWith("≤")) { | ||
return <>{version}</>; | ||
} | ||
const title = `Supported in version ${version.slice(1)} or earlier.`; | ||
const actionDescription = removed ? "ended" : "started"; | ||
const versionDescription = `version ${version.slice(1)} or earlier`; |
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.
Assuming version
has a value of ≤ 79
there would be a doubled space here.
Is it guaranteed to be in shape of ≤79
?
(79 being a random number)
const title = `Supported in version ${version.slice(1)} or earlier.`; | ||
const actionDescription = removed ? "ended" : "started"; | ||
const versionDescription = `version ${version.slice(1)} or earlier`; | ||
const title = `Support ${actionDescription} in ${versionDescription} (specific version unknown)`; | ||
return ( | ||
<span title={title}> | ||
<sup>≤ </sup> |
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.
<sup>≤ </sup> | |
<sup>≤<NonBreakingSpace /></sup> |
(for readability)
In #3238 a proposal was made to hide the "≤" annotation altogether to avoid confusion and we came to agreement there, so I think this PR should be closed. Thanks for your work, though! |
Closing, but thanks for all of your work on this @cincodenada! |
Oh, yeah reading up on #3238 I agree that is the better solution overall, the <= doesn't really add much information in this context, so if we can just clear up the confusion by leaving it out I'm all for it! Thanks for looping back here and for all the feedback in the process, even though it ended up being superceded :) |
Thanks @cincodenada! Your work definitely also helped us to realize what is best 👍 |
The existing tooltip can easily be read as implying the feature is only supported in the given range, rather than support starting in that range. It's doubly confusing when the removed version is <=, because the tooltip is written primarily for the added case.
I considered creating an enum rather than
'added'
/'removed'
magic string values, or just having a boolean e.g.isAdded
, so I'm open to suggestions on how to communicate the difference between those cases.Examples of what this looks like in practice:
:last-child
-webkit-mask-attachment
(Edit: I have now gotten it set up locally and it seems to work as expected 👍)