From 52b0f285c6eef7482b34a2bea69369a91c1e28c1 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 20 May 2019 20:41:48 -0600 Subject: [PATCH] Add some clarifying comments --- res/css/_common.scss | 4 ++++ src/components/structures/LoggedInView.js | 4 ++++ src/utils/Accessibility.js | 11 ++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/res/css/_common.scss b/res/css/_common.scss index ba239b8ca8..5c64fc4c1a 100644 --- a/res/css/_common.scss +++ b/res/css/_common.scss @@ -110,6 +110,10 @@ textarea { color: $primary-fg-color; } +// This is used to hide the standard outline added by browsers for +// accessible (focusable) components. Not intended for buttons, but +// should be used on things like focusable containers where the outline +// is usually not helping anyone. .mx_HiddenFocusable { outline: none; } diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.js index 130a3bf055..0ad2f72cfc 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.js @@ -323,6 +323,10 @@ const LoggedInView = React.createClass({ } break; case KeyCode.KEY_I: + // Ideally this would be CTRL+P for "Profile", but that's + // taken by the print dialog. CTRL+I for "Information" + // will have to do. + if (ctrlCmdOnly) { dis.dispatch({ action: 'toggle_top_left_menu', diff --git a/src/utils/Accessibility.js b/src/utils/Accessibility.js index 8c6090671d..c04d6e0d9b 100644 --- a/src/utils/Accessibility.js +++ b/src/utils/Accessibility.js @@ -14,6 +14,15 @@ See the License for the specific language governing permissions and limitations under the License. */ +/** + * Automatically focuses the captured reference when receiving a non-null + * object. Useful in scenarios where componentDidMount does not have a + * useful reference to an element, but one needs to focus the element on + * first render. Example usage: ref={focusCapturedRef} + * @param ref The React reference to focus on, if not null + */ export function focusCapturedRef(ref) { - if (ref) ref.focus(); + if (ref) { + ref.focus(); + } }