Skip to content

Commit

Permalink
PLT-3473 Made shortcuts only work for CMD on OSX (mattermost#3479)
Browse files Browse the repository at this point in the history
* checked for CMD key

* changed method of checking
  • Loading branch information
DavidLu1997 authored and crspeller committed Jul 6, 2016
1 parent 1557d2b commit 295cdf9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components/channel_header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default class ChannelHeader extends React.Component {
}

openRecentMentions(e) {
if ((e.ctrlKey || e.metaKey) && e.shiftKey && e.keyCode === Constants.KeyCodes.M) {
if (Utils.cmdOrCtrlPressed(e) && e.shiftKey && e.keyCode === Constants.KeyCodes.M) {
e.preventDefault();
this.searchMentions(e);
}
Expand Down
2 changes: 1 addition & 1 deletion components/file_upload.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class FileUpload extends React.Component {
}

keyUpload(e) {
if ((e.ctrlKey || e.metaKey) && e.keyCode === Constants.KeyCodes.U) {
if (Utils.cmdOrCtrlPressed(e) && e.keyCode === Constants.KeyCodes.U) {
e.preventDefault();
if (this.props.postType === 'post' && document.activeElement.id === 'post_textbox' || this.props.postType === 'comment' && document.activeElement.id === 'reply_textbox') {
$(this.refs.fileInput).focus().trigger('click');
Expand Down
2 changes: 1 addition & 1 deletion components/navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export default class Navbar extends React.Component {
});
}
showChannelSwitchModal(e) {
if ((e.ctrlKey || e.metaKey) && e.keyCode === Constants.KeyCodes.K) {
if (Utils.cmdOrCtrlPressed(e) && e.keyCode === Constants.KeyCodes.K) {
e.preventDefault();
this.setState({
showChannelSwitchModal: true
Expand Down
2 changes: 1 addition & 1 deletion components/navbar_dropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default class NavbarDropdown extends React.Component {
document.removeEventListener('keydown', this.openAccountSettings);
}
openAccountSettings(e) {
if ((e.ctrlKey || e.metaKey) && e.shiftKey && e.keyCode === Constants.KeyCodes.A) {
if (Utils.cmdOrCtrlPressed(e) && e.shiftKey && e.keyCode === Constants.KeyCodes.A) {
e.preventDefault();
this.setState({showUserSettingsModal: true});
}
Expand Down
8 changes: 8 additions & 0 deletions utils/utils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ export function cleanUpUrlable(input) {
return cleaned;
}

export function isMac() {
return navigator.platform.toUpperCase().indexOf('MAC') >= 0;
}

export function cmdOrCtrlPressed(e) {
return (isMac() && e.metaKey) || (!isMac() && e.ctrlKey);
}

export function isChrome() {
if (navigator.userAgent.indexOf('Chrome') > -1) {
return true;
Expand Down

0 comments on commit 295cdf9

Please sign in to comment.