Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

[MM-22800]_add keyboard shortcuts to tooltips #8896

Merged
merged 9 commits into from
Sep 23, 2021
Prev Previous commit
Next Next commit
minor code clean up and reverting the normalizeShortcutDescriptor cod…
…e snippet
  • Loading branch information
AshishDhama committed Sep 21, 2021
commit 7407d4963a7fdfe7ed063a7f94e8d151ce54f97a
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,6 @@
margin-right: 5px;
}
}

// TODO: It probably makes sense to switch to <ShortcutKey> component
// in order to have universal shortcut key appearance
.shortcut-key {
padding: 4px 6px;
margin: 5px 0 5px 5px;
border-radius: 3px;
font-size: 12px;
font-weight: 500;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@ type Props = {
isInsideTooltip?: boolean;
};

const descriptorProperty = isMac() ? 'mac' : 'default';

function normalizeShortcutDescriptor(shortcut: KeyboardShortcutDescriptor) {
if (isMessageDescriptor(shortcut)) {
return shortcut;
}

// return the default descriptor when there is no mac specific descriptor
return shortcut[descriptorProperty] || shortcut.default;
const {default: standard, mac} = shortcut;
return isMac() && mac ? mac : standard;
}

const KEY_SEPARATOR = '|';
Expand Down
8 changes: 4 additions & 4 deletions components/search_shortcut/search_shortcut.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// See LICENSE.txt for license information.
import React from 'react';

import {ShortcutKey, ShortcutKetVariant} from 'components/shortcut_key';
import {ShortcutKey, ShortcutKeyVariant} from 'components/shortcut_key';

import {isMac} from 'utils/utils.jsx';
import {isDesktopApp} from 'utils/user_agent';
Expand All @@ -13,9 +13,9 @@ export const SearchShortcut = () => {

return (
<span className='search-shortcut'>
<ShortcutKey variant={ShortcutKetVariant.Contrast}>{controlKey}</ShortcutKey>
{!isDesktopApp() && <ShortcutKey variant={ShortcutKetVariant.Contrast}>{'Shift'}</ShortcutKey>}
<ShortcutKey variant={ShortcutKetVariant.Contrast}>{'F'}</ShortcutKey>
<ShortcutKey variant={ShortcutKeyVariant.Contrast}>{controlKey}</ShortcutKey>
{!isDesktopApp() && <ShortcutKey variant={ShortcutKeyVariant.Contrast}>{'Shift'}</ShortcutKey>}
<ShortcutKey variant={ShortcutKeyVariant.Contrast}>{'F'}</ShortcutKey>
</span>
);
};
4 changes: 2 additions & 2 deletions components/shortcut_key/shortcut_key.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React from 'react';
import {shallow} from 'enzyme';

import {ShortcutKey, ShortcutKetVariant} from './shortcut_key';
import {ShortcutKey, ShortcutKeyVariant} from './shortcut_key';

describe('components/ShortcutKey', () => {
test('should match snapshot for regular key', () => {
Expand All @@ -12,7 +12,7 @@ describe('components/ShortcutKey', () => {
});

test('should match snapshot for contrast key', () => {
const wrapper = shallow(<ShortcutKey variant={ShortcutKetVariant.Contrast}>{'Shift'}</ShortcutKey>);
const wrapper = shallow(<ShortcutKey variant={ShortcutKeyVariant.Contrast}>{'Shift'}</ShortcutKey>);
expect(wrapper).toMatchSnapshot();
});
});