-
Notifications
You must be signed in to change notification settings - Fork 427
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
feat: [A11y] Add a button to skip to web widget #440
Conversation
9fcb341
to
b38b16b
Compare
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.
Hi @smansouri, thanks for doing this! Caught a couple of typos.
a1af7b4
to
e72b022
Compare
@@ -1,4 +1,5 @@ | |||
<a class="skip-navigation" tabindex="1" href="#main-content">{{t 'skip_navigation' }}</a> | |||
<a class="skip-to-chat-widget" tabindex="1" href="#launcher" >{{t 'skip_to_chat'}}</a> | |||
|
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 string is "Skip to Chat" https://github.com/zendesk/help_center/blob/main/config/locales/translations/help_center.en.yml#L6830
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.
@zendesk-lzingarelli @jgorfine-zendesk I understand the suggestion to use Skip to chat
is to make it more understandable for users. However, the web widget can provide other functions besides chat. From the docs, a user can:
- Search help center articles for immediate self-service.
- Submit a support request using a contact form.
- Request a callback, or view a phone number that they can call instead.
- Start a live chat with an agent.
It's also possible to configure the widget to not provide a chat, in which case this string will be misleading. Could we reconsider it?
Currently, the web widget renders with a title
with a Opens a widget where you can find more information
value. From that perspective, wouldn't it be consistent if we use Skip to widget
instead?

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.
I had added a string for skip to Web Widget
before. Is that ok or you think it should be widget and not have web.
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.
For some reason the translation for skip_to_web_widget
is not found, although the translations were merged long time ago in HC
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.
I think you also need to add the string to the I18nKeysMapping hash used by the t
helper
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.
Thanks I made a PR https://github.com/zendesk/help_center/pull/28668
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.
LGTM 🙌
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.
Thanks for working on this Sara and sorry for the delayed review 🙈
I added some comments as I have some concerns with this solution. Please let me know what you think or if you'd like to go through the comments together.
I'd also like to ask @zendesk/emu to review this PR as owners of the web widget EUX.
src/navigation.js
Outdated
if (!chatWidget) { | ||
skipButton.style.display = "none"; | ||
} | ||
}, 500); |
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.
Since the theme does not have control on the markup and behaviour of the widget, this logic creates some coupling between the widget and the theme. For example, this logic will break:
- if the web widget changes its markup and does not render an iframe with
launcher
as id; - if the web widget changes its logic so it takes longer than 500ms to render these elements;
For this reason, I suggest relying on the public API of the widget as I believe that would be a more stable and robust solution. If a widget is present, there should be a zE
function defined in the window
object.
So in order to check if the widget is present, we could do the following:
if (window.zE) {
// there is a widget
} else {
// there is not a widget
}
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.
Then, a Help Center can have 2 types of widgets: classic and messenger.
- Messenger seems to support
zE('messenger', 'open')
to open the widget (docs). - Classic seems to support
zE('webWidget', 'open')
to open the widget (docs).
So we could use a logic like this, to open the widget after clicking the button:
const skipToWidgetButton = document.querySelector("#skipToWidget");
if (window.zE) {
// web widget is present, add logic to open both the classic and the messenger widget
skipToWidgetButton.addEventListener("click", () => window.zE(
window.zE.widget === "classic" ? "webWidget" : "messenger", "open"
));
} else {
// no web widget is present
skipToWidget.style.display = "none";
}
What do you think @smansouri? It would also be nice to have @zendesk/emu blessing on this one, to make sure we are not missing something.
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.
Thanks Andre, I changed it to use zE which is indeed better than looking for id. However even with this we still need to have some delay since the zE.widget is loaded after some milliseconds which you see it in this recording.
280727644-08f82789-4133-4347-9122-1070255d5599.mov
Update: Bence suggested to change this to poll the zE in a time interval.
The click handler with open method works very well 🙏
@@ -1,4 +1,5 @@ | |||
<a class="skip-navigation" tabindex="1" href="#main-content">{{t 'skip_navigation' }}</a> | |||
<a class="skip-to-chat-widget" tabindex="1" href="#launcher" >{{t 'skip_to_chat'}}</a> | |||
|
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.
@zendesk-lzingarelli @jgorfine-zendesk I understand the suggestion to use Skip to chat
is to make it more understandable for users. However, the web widget can provide other functions besides chat. From the docs, a user can:
- Search help center articles for immediate self-service.
- Submit a support request using a contact form.
- Request a callback, or view a phone number that they can call instead.
- Start a live chat with an agent.
It's also possible to configure the widget to not provide a chat, in which case this string will be misleading. Could we reconsider it?
Currently, the web widget renders with a title
with a Opens a widget where you can find more information
value. From that perspective, wouldn't it be consistent if we use Skip to widget
instead?

8bab8aa
to
73e4eaf
Compare
4fc0d1e
to
0eed465
Compare
0eed465
to
b20b6fd
Compare
a7a5402
to
484762f
Compare
Closing this, since I couldn't get it approved. |
Description
This PR adds a button to skip to web widget using keyboard navigation.
The last commit is to make the skip navigations links to not change color after clicking as this was requested from accessibility team.
The js code checks if the widget doesn't exist after 500 ms then it hides the skip button but I had to add a timeout since the widget is loaded after some delay. There might be some slow widgets that load after 500ms and then the skip button is not rendered or we can increase the delay to 1s to decrease this chance.
Screen.Recording.2024-01-08.at.12.57.23.mov
Jira: https://zendesk.atlassian.net/browse/GS-2485
Checklist