From f05d45ac9b17b77197373e0a04bdf0dcc768705b Mon Sep 17 00:00:00 2001 From: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com> Date: Fri, 2 Apr 2021 16:43:39 -0500 Subject: [PATCH] Pressing Esc in left pane composer menu should go back --- ts/components/LeftPane.tsx | 24 +++++++++++++- .../leftPane/LeftPaneArchiveHelper.tsx | 6 +++- .../LeftPaneChooseGroupMembersHelper.tsx | 10 +++++- .../leftPane/LeftPaneComposeHelper.tsx | 6 +++- ts/components/leftPane/LeftPaneHelper.tsx | 10 ++++++ .../LeftPaneSetGroupMetadataHelper.tsx | 10 +++++- .../leftPane/LeftPaneArchiveHelper_test.ts | 10 ++++++ .../LeftPaneChooseGroupMembersHelper_test.ts | 12 +++++++ .../leftPane/LeftPaneComposeHelper_test.ts | 13 ++++++++ .../leftPane/LeftPaneInboxHelper_test.ts | 19 +++++++++++ .../leftPane/LeftPaneSearchHelper_test.ts | 20 +++++++++++ .../LeftPaneSetGroupMetadataHelper_test.ts | 33 +++++++++++++++++++ 12 files changed, 168 insertions(+), 5 deletions(-) diff --git a/ts/components/LeftPane.tsx b/ts/components/LeftPane.tsx index ebd220bfbd..79d6afa5be 100644 --- a/ts/components/LeftPane.tsx +++ b/ts/components/LeftPane.tsx @@ -348,8 +348,30 @@ export const LeftPane: React.FC = ({ // It also ensures that we scroll to the top when switching views. const listKey = preRowsNode ? 1 : 0; + // We disable this lint rule because we're trying to capture bubbled events. See [the + // lint rule's docs][0]. + // + // [0]: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/645900a0e296ca7053dbf6cd9e12cc85849de2d5/docs/rules/no-static-element-interactions.md#case-the-event-handler-is-only-being-used-to-capture-bubbled-events + /* eslint-disable jsx-a11y/no-static-element-interactions */ return ( -
+
{ + if (event.key === 'Escape') { + const backAction = helper.getBackAction({ + showInbox, + startComposing, + showChooseGroupMembers, + }); + if (backAction) { + event.preventDefault(); + event.stopPropagation(); + backAction(); + } + } + }} + > + {/* eslint-enable jsx-a11y/no-static-element-interactions */}
{helper.getHeaderContents({ i18n, diff --git a/ts/components/leftPane/LeftPaneArchiveHelper.tsx b/ts/components/leftPane/LeftPaneArchiveHelper.tsx index 634bbc9cbb..1a2715dd89 100644 --- a/ts/components/leftPane/LeftPaneArchiveHelper.tsx +++ b/ts/components/leftPane/LeftPaneArchiveHelper.tsx @@ -39,7 +39,7 @@ export class LeftPaneArchiveHelper extends LeftPaneHelper< return (