From 3747879413c32bab72f36a75a0483e3b79bfd4dd Mon Sep 17 00:00:00 2001 From: DarkSky <25152247+darkskygit@users.noreply.github.com> Date: Sat, 19 Sep 2026 20:41:04 +0800 Subject: [PATCH] fix(core): linux redo shortcut key (#15623) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #15599 #### PR Dependency Tree * **PR #15623** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) ## Summary by CodeRabbit * **Bug Fixes** * Corrected the Control+Y redo shortcut so it only activates on Windows and Linux, preventing unintended behavior on other platforms. * **Tests** * Updated cross-platform keyboard tests to explicitly verify undo and redo behavior in a Linux browser environment. --- .../affine/blocks/root/src/keyboard/keyboard-manager.ts | 4 ++-- tests/blocksuite/e2e/cross-platform/basic.spec.ts | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/blocksuite/affine/blocks/root/src/keyboard/keyboard-manager.ts b/blocksuite/affine/blocks/root/src/keyboard/keyboard-manager.ts index 74ce190eb6..e19db53687 100644 --- a/blocksuite/affine/blocks/root/src/keyboard/keyboard-manager.ts +++ b/blocksuite/affine/blocks/root/src/keyboard/keyboard-manager.ts @@ -11,7 +11,7 @@ import { getSelectedModelsCommand, } from '@blocksuite/affine-shared/commands'; import { matchModels } from '@blocksuite/affine-shared/utils'; -import { IS_MAC, IS_WINDOWS } from '@blocksuite/global/env'; +import { IS_LINUX, IS_MAC, IS_WINDOWS } from '@blocksuite/global/env'; import { type BlockComponent, BlockSelection, @@ -98,7 +98,7 @@ export class PageKeyboardManager { } }, 'Control-y': ctx => { - if (!IS_WINDOWS) return; + if (!IS_WINDOWS && !IS_LINUX) return; ctx.get('defaultState').event.preventDefault(); if (this._doc.canRedo) { diff --git a/tests/blocksuite/e2e/cross-platform/basic.spec.ts b/tests/blocksuite/e2e/cross-platform/basic.spec.ts index 56eab3d726..d31f519249 100644 --- a/tests/blocksuite/e2e/cross-platform/basic.spec.ts +++ b/tests/blocksuite/e2e/cross-platform/basic.spec.ts @@ -226,15 +226,20 @@ test(scoped`basic paired undo/redo`, async ({ page }) => { }); test(scoped`undo/redo with keyboard`, async ({ page }) => { + await page.addInitScript(() => { + Object.defineProperty(navigator, 'platform', { + get: () => 'Linux x86_64', + }); + }); await enterPlaygroundRoom(page); await initEmptyParagraphState(page); await focusRichText(page); await type(page, 'hello'); await assertText(page, 'hello'); - await undoByKeyboard(page); + await page.keyboard.press('Control+z'); await assertEmpty(page); - await redoByClick(page); + await page.keyboard.press('Control+y'); await assertText(page, 'hello'); });