Skip to content

Commit

Permalink
fix: consecutive selection
Browse files Browse the repository at this point in the history
Determine the key modifier based on the host OS, use 'CMD' for Mac and 'Ctrl' for other OS.

close #2664
  • Loading branch information
hamed-musallam committed Sep 13, 2023
1 parent d3d231f commit 53fff90
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/component/context/KeyModifierContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interface KeyModifierProviderProps {
const isMac =
navigator !== undefined && navigator.userAgent.toLowerCase().includes('mac');

function getModifiers(event: KeyboardEvent) {
export function getModifiers(event: KeyboardEvent) {
const { shiftKey, altKey, metaKey } = event;
const ctrlKey = isMac ? metaKey : event.ctrlKey;
return { ctrlKey, shiftKey, altKey };
Expand Down
6 changes: 4 additions & 2 deletions src/component/panels/SpectrumsPanel/SpectrumsTabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import groupByInfoKey from '../../utility/GroupByInfoKey';

import { SpectraTable } from './SpectraTable';
import SpectrumSetting from './base/setting/SpectrumSetting';
import { getModifiers } from '../../context/KeyModifierContext';

interface SpectrumsTabsInnerProps {
data: Spectrum[];
Expand Down Expand Up @@ -68,8 +69,9 @@ function SpectrumsTabsInner({

function handleChangeActiveSpectrum(e, spectrum) {
setTimeout(() => {
const modifier = `shift[${e.shiftKey ? 'true' : 'false'}]_ctrl[${
e.ctrlKey ? 'true' : 'false'
const { ctrlKey, shiftKey } = getModifiers(e);
const modifier = `shift[${shiftKey ? 'true' : 'false'}]_ctrl[${
ctrlKey ? 'true' : 'false'
}]`;
dispatch({
type: 'CHANGE_ACTIVE_SPECTRUM',
Expand Down

0 comments on commit 53fff90

Please sign in to comment.