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

removes the dev mode access key binding safeguard #15044

Merged
merged 3 commits into from
Apr 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/components/src/keyboard-shortcuts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import { forEach } from 'lodash';
*/
import { Component, Children } from '@wordpress/element';

/**
* Internal dependencies
*/
import { isAppleOS } from './platform';

class KeyboardShortcuts extends Component {
constructor() {
super( ...arguments );
Expand All @@ -30,8 +35,10 @@ class KeyboardShortcuts extends Component {
const hasShift = modifiers.has( 'shift' );

if (
( modifiers.size === 1 && hasAlt ) ||
( modifiers.size === 2 && hasAlt && hasShift )
isAppleOS() && (
( modifiers.size === 1 && hasAlt ) ||
( modifiers.size === 2 && hasAlt && hasShift )
)
) {
throw new Error( `Cannot bind ${ key }. Alt and Shift+Alt modifiers are reserved for character input.` );
}
Expand Down
18 changes: 18 additions & 0 deletions packages/components/src/keyboard-shortcuts/platform.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* External dependencies
*/
import { includes } from 'lodash';

/**
* Return true if platform is MacOS.
*
* @param {Object} _window window object by default; used for DI testing.
Copy link
Member

Choose a reason for hiding this comment

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

We're not using it here, so it can be removed?

*
* @return {boolean} True if MacOS; false otherwise.
*/
export function isAppleOS( _window = window ) {
const { platform } = _window.navigator;

return platform.indexOf( 'Mac' ) !== -1 ||
includes( [ 'iPad', 'iPhone' ], platform );
}