Skip to content

Commit

Permalink
show standalone keyboard shortcuts help page when screenreader enabled
Browse files Browse the repository at this point in the history
- Fixes #6118
- Also emit an announcement if user brings up the VIM help pane (:help in editor) warning that VIM help isn't screen reader accessible, will open a separate issue on making VIM help accessible (don't consider a high priority)
- Not impossible to make the popup panel accessible, but not trivial, either; needs to do the things a modal dialog does (make rest of UI inert, provide a way to close with keyboard and mouse that isn't simply "click anywhere, type anything", then ensure the content of the panel is reasonably accessible)
  • Loading branch information
gtritchie committed Jan 30, 2020
1 parent 866115d commit 7f5fe86
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 deletions.
47 changes: 34 additions & 13 deletions src/gwt/src/org/rstudio/core/client/command/ShortcutViewer.java
@@ -1,7 +1,7 @@
/*
* ShortcutViewer.java
*
* Copyright (C) 2009-12 by RStudio, Inc.
* Copyright (C) 2009-20 by RStudio, Inc.
*
* Unless you have received this program directly from RStudio pursuant
* to the terms of a commercial license agreement with RStudio, then
Expand All @@ -16,9 +16,13 @@
package org.rstudio.core.client.command;


import com.google.inject.Provider;
import org.rstudio.core.client.widget.ShortcutInfoPanel;
import org.rstudio.core.client.widget.VimKeyInfoPanel;
import org.rstudio.studio.client.application.AriaLiveService;
import org.rstudio.studio.client.application.Desktop;
import org.rstudio.studio.client.application.events.AriaLiveStatusEvent.Severity;
import org.rstudio.studio.client.application.events.AriaLiveStatusEvent.Timing;
import org.rstudio.studio.client.common.GlobalDisplay;
import org.rstudio.studio.client.workbench.commands.Commands;

Expand All @@ -34,6 +38,7 @@
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.rstudio.studio.client.workbench.prefs.model.UserPrefs;

@Singleton
public class ShortcutViewer implements NativePreviewHandler
Expand All @@ -44,10 +49,13 @@ public interface Binder extends CommandBinder<Commands, ShortcutViewer> {}
public ShortcutViewer(
Binder binder,
Commands commands,
Provider<UserPrefs> pPrefs,
Provider<AriaLiveService> pAriaLive,
GlobalDisplay globalDisplay)
{
binder.bind(commands, this);

pPrefs_ = pPrefs;
pAriaLive_ = pAriaLive;
globalDisplay_ = globalDisplay;
}

Expand All @@ -59,17 +67,19 @@ public void onHelpKeyboardShortcuts()
{
return;
}
showShortcutInfoPanel(new ShortcutInfoPanel(new Command()

Command showAllShortcutsPage = ()->
{
@Override
public void execute()
{
if (Desktop.hasDesktopFrame())
Desktop.getFrame().showKeyboardShortcutHelp();
else
openApplicationURL("docs/keyboard.htm");
}
}));
if (Desktop.hasDesktopFrame())
Desktop.getFrame().showKeyboardShortcutHelp();
else
openApplicationURL("docs/keyboard.htm");
};

if (pPrefs_.get().getScreenReaderEnabled())
showAllShortcutsPage.execute();
else
showShortcutInfoPanel(new ShortcutInfoPanel(showAllShortcutsPage));
}

public void showVimKeyboardShortcuts()
Expand All @@ -79,6 +89,13 @@ public void showVimKeyboardShortcuts()
{
return;
}
if (pPrefs_.get().getScreenReaderEnabled())
{
pAriaLive_.get().announce(AriaLiveService.INACCESSIBLE_FEATURE,
"Vim keyboard shortcut help not screen reader accessible. Press any key to close.",
Timing.IMMEDIATE,
Severity.ALERT);
}
showShortcutInfoPanel(new VimKeyInfoPanel());
}

Expand Down Expand Up @@ -135,5 +152,9 @@ private void openApplicationURL(String relativeURL)

private ShortcutInfoPanel shortcutInfo_ = null;
private HandlerRegistration preview_;
private GlobalDisplay globalDisplay_;

// injected
private final Provider<UserPrefs> pPrefs_;
private final Provider<AriaLiveService> pAriaLive_;
private final GlobalDisplay globalDisplay_;
}
Expand Up @@ -39,6 +39,7 @@ public class AriaLiveService
public static final String CONSOLE_LOG = "console_log";
public static final String FILTERED_LIST = "filtered_list";
public static final String GIT_MESSAGE_LENGTH = "git_message_length";
public static final String INACCESSIBLE_FEATURE = "inaccessible_feature";
public static final String INFO_BAR = "info_bar";
public static final String PROGRESS_COMPLETION = "progress_completion";
public static final String PROGRESS_LOG = "progress_log";
Expand Down Expand Up @@ -66,6 +67,7 @@ public AriaLiveService(EventBus eventBus, Provider<UserPrefs> pUserPrefs)
announcements_.put(CONSOLE_LOG, "Console output (requires restart)");
announcements_.put(FILTERED_LIST, "Filtered result count");
announcements_.put(GIT_MESSAGE_LENGTH, "Commit message length");
announcements_.put(INACCESSIBLE_FEATURE, "Inaccessible feature warning");
announcements_.put(INFO_BAR, "Info bars");
announcements_.put(PROGRESS_COMPLETION, "Task completion");
announcements_.put(PROGRESS_LOG, "Task progress details");
Expand Down

0 comments on commit 7f5fe86

Please sign in to comment.