mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
fix(editor): Fix canvas selection for touch devices that use mouse (#9036)
This commit is contained in:
parent
571b6135dd
commit
286fa5cd7e
|
@ -69,12 +69,5 @@ describe('useDeviceSupport()', () => {
|
||||||
const event = new KeyboardEvent('keydown', { ctrlKey: true });
|
const event = new KeyboardEvent('keydown', { ctrlKey: true });
|
||||||
expect(isCtrlKeyPressed(event)).toEqual(true);
|
expect(isCtrlKeyPressed(event)).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return true for touch device on MouseEvent', () => {
|
|
||||||
Object.defineProperty(window, 'ontouchstart', { value: {} });
|
|
||||||
const { isCtrlKeyPressed } = useDeviceSupport();
|
|
||||||
const mockEvent = new MouseEvent('click');
|
|
||||||
expect(isCtrlKeyPressed(mockEvent)).toEqual(true);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,9 +12,6 @@ export function useDeviceSupport() {
|
||||||
const controlKeyCode = ref(isMacOs.value ? 'Meta' : 'Control');
|
const controlKeyCode = ref(isMacOs.value ? 'Meta' : 'Control');
|
||||||
|
|
||||||
function isCtrlKeyPressed(e: MouseEvent | KeyboardEvent): boolean {
|
function isCtrlKeyPressed(e: MouseEvent | KeyboardEvent): boolean {
|
||||||
if (isTouchDevice.value && e instanceof MouseEvent) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (isMacOs.value) {
|
if (isMacOs.value) {
|
||||||
return (e as KeyboardEvent).metaKey;
|
return (e as KeyboardEvent).metaKey;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue