Closed jessegreenberg closed 6 years ago
@jessegreenberg, I have some notes on this.
The idea for the link to a button rather than a direct button was to make it a little less desirable on initial startup. We don't want it to get in the way. However, for people who really need it, they are told right away where it is.
My earlier research convinced me that it was legal to link to a button on page, though it is not super common.
@jessegreenberg , what do you mean by no destination? Is the navbar not there on screen load?
I see, thanks.
My earlier research convinced me that it was legal to link to a button on page, though it is not super common.
Interesting, I didn't realize that. I am not too sure yet how that would work.
what do you mean by no destination?
I meant that I don't know what the href would be, I don't know what the link would point to.
Is the link going to open the dialog or send focus to the button in the navigation bar?
@jessegreenberg, the idea was to link to the button, not open the dialog. If we take this approach,
the href
for the anchor would be the id
of the button
.
<a href="keyboard-shorcuts-button>keyboard shortcuts</a>
...sim content here...
<button id="keyboard-shortcuts-button">keyboard shortcuts</button>
I see thanks! It looks like if we prefix the id with a '#', it should work.
Hmm, but that updates the url, is that reloading the page?
@jessegreenberg, good catch. Yes, internal page links are added to the url. I don't know about page refreshing, but that url would take focus to the button and not the top of the sim if someone were to copy and paste the link into another browser tab.
Scenery might not support this out of the box. Since scenery doesn't use DOM id's anymore we will need to add a way to get the id for the href. We will also need to make sure that we can add this in a secure way. Including a link in a translatable description might will introduce cross site scripting vulnerabilities.
Hmm, but that updates the url, is that reloading the page?
Some google searching says it will not reload the page.
but that url would take focus to the button and not the top of the sim if someone were to copy and paste the link into another browser tab.
I am not sure if that is a problem, what do you think @terracoda?
@jessegreenberg, as long as the url works, I don't think it is a problem.
Not sure if this is supported, but if we're trying to simply move focus to the dialog button, we could also utilize data attributes. That might offer a cleaner/more secure way to interact with Scenery. This also wouldn't append '#...' to the url.
@mbarlow12 and I discussed potentially adding data attributes as a way to manage focus. We also talked about using a click listener instead of href
as a way to send focus to the button, and this would likely integrate with Scenery more directly, and also wouldn't modify the URL at all.
@terracoda are you OK with the link not being in the focus order?
EDIT: particularly because it is 'invisible' to sighted users and there won't be anything to focus?
Click event works great, thanks @mbarlow12.
So now we need to solve two more issues:
Since there is only one KeyboardHelpButton in a sim, we can use a singleton pattern and get the instance statically from anywhere.
The string for the link needs to be translatable, and the formatting needs to work for RTL languages.
It seems that PhET does not support embedding links in text, this doesn't work for internationalization. Here is what I have been thinking:
@terracoda a couple of potential solutions are:
<a>If needed, check out the keyboard help dialog for this sim</a>
<p>If needed, check out the keyboard help dialog for this sim.<p>
<a>Keyboard Help Button</a>
I prefer the first option.
@jessegreenberg,
All sounds good @terracoda, thanks. Reassigning to me to implement.
It sounds like RichText will now support adding arbitrary callbacks to the links, which means that we should be able to support the original scene summary item with an embedded link in a way that is safe and i18n friendly!
If needed, check out the <a>keyboard help</a> for more information
(thats might not be the exact working)
@jessegreenberg, I had
If you need to, check out
<a href="#keyboard-shortcuts">keyboard shortcuts</a>
for this sim.
However,
If needed, check out
<a href="#keyboard-shortcuts">keyboard shortcuts</a>
for this sim.
is shorter.
As discussed in the Ohm's Law repo https://github.com/phetsims/ohms-law/issues/99, we are putting this idea on hold, as the link be the first item in the tab order for all sims...likely not what we want.
Providing the hint that help for keyboard use exists is likely just enough:
We are trying these phrases in BASE and OL.
Closing this issue.
In the scene summary for a few sims I have seen a bullet that looks like
The keyboard help dialog is typically opened with a button that just toggles its visibility. Is this shortcut necessary? If so can it be a button? If a link, is it OK if there is no destination?