fix(editor): Restore V1 keybinding, Space Key to toggle panning (#10841)

This commit is contained in:
Raúl Gómez Morales 2024-09-18 09:10:51 +02:00 committed by GitHub
parent c1d88f3bb3
commit 5a1db6db1a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 5 deletions

View file

@ -164,7 +164,7 @@ describe('Canvas', () => {
const pane = canvas.querySelector('.vue-flow__pane'); const pane = canvas.querySelector('.vue-flow__pane');
if (!pane) throw new Error('VueFlow pane not found'); if (!pane) throw new Error('VueFlow pane not found');
await fireEvent.keyDown(pane, { view: window, key: 'Shift' }); await fireEvent.keyDown(pane, { view: window, key: ' ' });
await fireEvent.mouseDown(pane, { view: window }); await fireEvent.mouseDown(pane, { view: window });
await fireEvent.mouseMove(pane, { await fireEvent.mouseMove(pane, {
view: window, view: window,
@ -172,7 +172,7 @@ describe('Canvas', () => {
clientY: 100, clientY: 100,
}); });
await fireEvent.mouseUp(pane, { view: window }); await fireEvent.mouseUp(pane, { view: window });
await fireEvent.keyUp(pane, { view: window, key: 'Shift' }); await fireEvent.keyUp(pane, { view: window, key: ' ' });
vi.advanceTimersByTime(minimapTransitionDuration); vi.advanceTimersByTime(minimapTransitionDuration);
await waitFor(() => expect(getByTestId('canvas-minimap')).toBeVisible()); await waitFor(() => expect(getByTestId('canvas-minimap')).toBeVisible());
@ -196,7 +196,7 @@ describe('Canvas', () => {
const pane = canvas.querySelector('.vue-flow__pane'); const pane = canvas.querySelector('.vue-flow__pane');
if (!pane) throw new Error('VueFlow pane not found'); if (!pane) throw new Error('VueFlow pane not found');
await fireEvent.keyDown(pane, { view: window, key: 'Shift' }); await fireEvent.keyDown(pane, { view: window, key: ' ' });
await fireEvent.mouseDown(pane, { view: window }); await fireEvent.mouseDown(pane, { view: window });
await fireEvent.mouseMove(pane, { await fireEvent.mouseMove(pane, {
view: window, view: window,
@ -204,7 +204,7 @@ describe('Canvas', () => {
clientY: 100, clientY: 100,
}); });
await fireEvent.mouseUp(pane, { view: window }); await fireEvent.mouseUp(pane, { view: window });
await fireEvent.keyUp(pane, { view: window, key: 'Shift' }); await fireEvent.keyUp(pane, { view: window, key: ' ' });
vi.advanceTimersByTime(minimapTransitionDuration); vi.advanceTimersByTime(minimapTransitionDuration);
await waitFor(() => expect(getByTestId('canvas-minimap')).toBeVisible()); await waitFor(() => expect(getByTestId('canvas-minimap')).toBeVisible());

View file

@ -122,7 +122,10 @@ const classes = computed(() => ({
const disableKeyBindings = computed(() => !props.keyBindings); const disableKeyBindings = computed(() => !props.keyBindings);
const panningKeyCode = 'Shift'; /**
* @see https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values#whitespace_keys
*/
const panningKeyCode = ' ';
const isPanningEnabled = ref(false); const isPanningEnabled = ref(false);
onKeyDown(panningKeyCode, () => { onKeyDown(panningKeyCode, () => {