Small optimization for faster loading (gaining ~80ms - average time of a click) It might seem a little over-engineered but there are a lot of edge cases and I couldn't find a simpler solution I also tried to tackle Link Chips but it's more complex so this will be for another PR
17 lines
389 B
TypeScript
17 lines
389 B
TypeScript
type LimitedMouseEvent = Pick<
|
|
MouseEvent,
|
|
'button' | 'metaKey' | 'altKey' | 'ctrlKey' | 'shiftKey'
|
|
>;
|
|
|
|
export const isNavigationModifierPressed = ({
|
|
altKey,
|
|
ctrlKey,
|
|
shiftKey,
|
|
metaKey,
|
|
button,
|
|
}: LimitedMouseEvent) => {
|
|
const pressedKey = [altKey, ctrlKey, shiftKey, metaKey].some((key) => key);
|
|
const isLeftClick = button === 0;
|
|
return pressedKey || !isLeftClick;
|
|
};
|