Skip to content
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

Added Keyboard shortcuts modal #6112

Merged
merged 41 commits into from
Nov 24, 2021

Conversation

akshayasalvi
Copy link
Contributor

@akshayasalvi akshayasalvi commented Oct 29, 2021

Details

  • Added help dialog for keyboard shortcuts list

Fixed Issues

$ #5588

Tests

  1. Checked keyboard shortcut with Desktop and Web
  2. Checked from Windows Browser for Ctrl + ? shortcut.
  3. Compared all the current keyboard shortcuts.

QA Steps

  1. On the sidebar click Cmd + ?
  2. It should open a dialog with the list of keyboard shortcuts.
  3. It should cover all the current keyboard shortcuts.

Tested On

  • Web
  • Mobile Web
  • Desktop
  • iOS
  • Android

Screenshots

Web

Screenshot 2021-11-08 at 9 28 02 PM

mobile-view-shortcuts-modal

Mobile Web

Desktop

Screenshot 2021-11-08 at 9 30 37 PM

iOS

Android

@akshayasalvi akshayasalvi requested a review from a team as a code owner October 29, 2021 12:45
@MelvinBot MelvinBot requested review from roryabraham and removed request for a team October 29, 2021 12:45
@akshayasalvi
Copy link
Contributor Author

akshayasalvi commented Oct 29, 2021

@roryabraham Need help with three things.

  1. Our current modal only supports full screen for the desktop

image

I feel should modify this to a centred modal. Can you help me understand a better approach here?
I've tried overriding modalContainerStyles it doesn't work. I can see we're using getModalStyles. Should I add a new style type in the modal switch block?

  1. I have used a combination of Views to create a Table grid. I didn't find any other component that can be used to create a table. Just left with the borderRadius.

  2. Need to verify spanish translations

Also @shawnborton Can you confirm the colors for the styling and if the borderRadius is required for the table?

@shawnborton
Copy link
Contributor

Can we use a smaller modal style for this? I don't think it needs to take up the full screen. I'm also curious to see what mobile looks like?

I think a border radius on the table would look nice. I don't think we need gray backgrounds for the left column cells either, perhaps we can just give those cells a right border.

@shawnborton
Copy link
Contributor

It also looks like the table is not using the correct font family.

@akshayasalvi
Copy link
Contributor Author

@shawnborton I've updated screenshots in GH Body.

I'm also curious to see what mobile looks like?
I haven't set any click trigger. Only keyboard shortcut trigger. Can you suggest what would be the trigger on the mobile?

It also looks like the table is not using the correct font family.
I didn't change/set anything specific as such previously. Now I've set fontFamily: GTA.

@roryabraham Can you please review this?

Copy link
Contributor

@roryabraham roryabraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This did not pass testing. Pressing CMD + ? opens a help menu on desktop:

image

src/languages/en.js Outdated Show resolved Hide resolved
@rosegrech rosegrech added the Waiting for copy User facing verbiage needs polishing label Nov 3, 2021
@rosegrech
Copy link

@roryabraham we use the waiting for copy label to get copy reviewed which I applied but it did not ping anyone. Do you know if that label does not work in these types of GHs?

@roryabraham
Copy link
Contributor

Sorry @rosegrech, I should've remembered that. It didn't work because this is a pull request, not an issue.

@rosegrech
Copy link

no worries @roryabraham good for me to know that.

Amazing catch, I see what you mean. It looks like the shortcuts are all about chat yeah?
What about something for vague like:

Save time with these handy keyboard shortcuts:

@akshayasalvi
Copy link
Contributor Author

Resolved conflicts and pushed. @roryabraham Any other changes required for this one?

src/libs/KeyboardShortcut/index.js Outdated Show resolved Hide resolved
src/styles/styles.js Outdated Show resolved Hide resolved
src/components/KeyboardShortcutsModal.js Outdated Show resolved Hide resolved
src/components/KeyboardShortcutsModal.js Outdated Show resolved Hide resolved
src/components/KeyboardShortcutsModal.js Outdated Show resolved Hide resolved
src/components/KeyboardShortcutsModal.js Outdated Show resolved Hide resolved
src/components/KeyboardShortcutsModal.js Outdated Show resolved Hide resolved
src/components/KeyboardShortcutsModal.js Outdated Show resolved Hide resolved
src/components/KeyboardShortcutsModal.js Outdated Show resolved Hide resolved
src/libs/Navigation/AppNavigator/AuthScreens.js Outdated Show resolved Hide resolved
@akshayasalvi
Copy link
Contributor Author

@roryabraham PR updated. But I was wondering if, after the new KEYBOARD_SHORTCUTS map, we should modify the subscribe function with just two params shortcutConfig, callback. We also move the captureOnInputs to the config itself.

and then the function calls be like ``

this.unsubscribeShortcutModal = KeyboardShortcut.subscribe(CONST.KEYBOARD_SHORTCUTS.SHORTCUT_MODAL.shortcutKey, () => {
    this.showKeyboardShortcutModal();
});

Copy link
Contributor

@roryabraham roryabraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall great progress! I love the work that we've done here to create an extensible framework for keyboard shortcuts in our app, and I think we are now very close to a final version.

I also want to thank you for your patience with me as we've iteratively improved this design in several rounds of reviews. Almost there, let's get this over the finish line!

src/components/KeyboardShortcutsModal.js Show resolved Hide resolved
isVisible={this.state.isOpen}
type={modalType}
containerStyle={styles.keyboardShortcutModalContainer}
onClose={() => this.hideKeyboardShortcutModal()}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
onClose={() => this.hideKeyboardShortcutModal()}
onClose={this.hideKeyboardShortcutModal}

containerStyle={styles.keyboardShortcutModalContainer}
onClose={() => this.hideKeyboardShortcutModal()}
>
<HeaderWithCloseButton title={this.props.translate('keyboardShortcutModal.title')} onCloseButtonPress={() => this.hideKeyboardShortcutModal()} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<HeaderWithCloseButton title={this.props.translate('keyboardShortcutModal.title')} onCloseButtonPress={() => this.hideKeyboardShortcutModal()} />
<HeaderWithCloseButton title={this.props.translate('keyboardShortcutModal.title')} onCloseButtonPress={this.hideKeyboardShortcutModal} />

function getKeyboardShortcuts() {
const shortcuts = [];
_.each(keyboardShortcutMap, (descriptionKey, key) => {
shortcuts.push({key, descriptionKey});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticing a subtle inconsistency here in that in CONST.js we define keyboard shortcuts as having the following shape:

{
    shortcutKey: String,
    descriptionKey: String,
    modifiers: Array<String>,
}

But here we're defining them with this a slightly different shape:

{
    key: String, // this is really a string with modifiers + the key,
    descriptionKey: String
}

So I find this similar but separate representation a bit confusing, and I think we could make this a bit clearer by having keyboardShortcutMap store a representation of keyboard shortcuts with the following shape:

{
    // The key that is pressed to initiate some action
    shortcutKey: String,
    
    // Modifier keys that also must be pressed with the shortcut key to initiate this action
    modifiers: Array<String>,
    
    // The human-readable representation of the shortcut with its modifiers (i.e: `CMD + SHIFT + K`)
    displayName: String,

    // A translation key for the full description of the action initiated by this keyboard shortcut    
    descriptionKey: String,
}

@akshayasalvi
Copy link
Contributor Author

@roryabraham PR updated

Copy link
Contributor

@roryabraham roryabraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is looking great! Thanks for making all those changes @akshayasalvi! Really happy with how this ended up.

@roryabraham roryabraham merged commit 36558e0 into Expensify:main Nov 24, 2021
@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@parasharrajat
Copy link
Member

Wow, This PR has whoopping 42 commits.

@parasharrajat parasharrajat mentioned this pull request Nov 24, 2021
4 tasks
@roryabraham
Copy link
Contributor

@akshayasalvi Just FYI, this PR caused a crash on iOS/Android because we renamed methods on KeyboardShortcut/index.js but didn't rename them on KeyboardShortcut/index.native.js. @parasharrajat Put up a fix in this PR, but it's something we should have caught before merging.

@akshayasalvi
Copy link
Contributor Author

akshayasalvi commented Nov 25, 2021

Noted @roryabraham. Sorry about that. Thanks for fixing @parasharrajat

@OSBotify
Copy link
Contributor

🚀 Deployed to staging by @roryabraham in version: 1.1.16-11 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

@ogumen
Copy link

ogumen commented Nov 30, 2021

The accessibility issues found in this PR:

  1. The X (Close) button fails minimum color contrast requirements of 3.00:1 against the background. The light grey button (#C6C9CA) against white background (#FFFFFF) has a color contrast ratio of 1.66:1 - failure of WCAG SC 1.4.11, similar to [med] Color Contrast: Many Pages: Grey icons against white background fail contrast requirements #5506
    Shortcuts dialog_Close button fails contrast requirements
  2. The visual dialog heading "Keyboard Shortcuts" is not implemented semantically as a heading and not announced as heading by screen reader - failure of WCAG SC 1.3.1, similar to [low] JAWS+Chrome: Many Pages: Visual headings are not announced as such #5458
    Shortcuts dialog_The dialog heading is not implemented semantically as a heading
  3. The shortcuts dialog has no semantic title provided, no label is announced by screen reader on dialog opening - failure of WCAG SC 1.3.1
    Shortcuts dialog_The modal has no semantic title provided
  4. Non-interactive dialog heading is focusable with Tab key - failure of WCAG SC 2.4.3
Non-interactive.Keyboard.Shortcuts.heading.is.focused.with.Tab.key.mp4
  1. The question mark in "Ctrl+?" command is not announced by screen reader - failure of WCAG SC 1.3.2. This issue may be fixed by hiding the visible command from the screen reader using aria-hidden attribute and adding an off-screen text "Control plus question mark" to provide this information to screen reader users.
The.question.mark.is.no.announced.as.part.of.keyboard.command.mp4

@OSBotify
Copy link
Contributor

OSBotify commented Dec 6, 2021

🚀 Deployed to production by @roryabraham in version: 1.1.17-7 🚀

platform result
🤖 android 🤖 success ✅
🖥 desktop 🖥 success ✅
🍎 iOS 🍎 success ✅
🕸 web 🕸 success ✅

* @returns {Array}
*/
function getKeyboardShortcuts() {
return _.values(keyboardShortcutMap);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has introduced a small regression in #18542.
In short, the order of keyboard shortcuts wasn't consistent across browsers, we solved this by using .sort()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants