Skip to content

fix(library): prevent right-click from deleting book group on Windows#487

Open
linze0721 wants to merge 1 commit into
codedogQBY:mainfrom
linze0721:fix/9ba88e1d-4406-4251-a605-5500f66a3332
Open

fix(library): prevent right-click from deleting book group on Windows#487
linze0721 wants to merge 1 commit into
codedogQBY:mainfrom
linze0721:fix/9ba88e1d-4406-4251-a605-5500f66a3332

Conversation

@linze0721

Copy link
Copy Markdown
Contributor

Summary

Fix right-click on book groups immediately deleting them on Windows instead of showing a context menu.

Closes #465

Root Cause

The group card and sidebar group components treated right-click the same as a regular click/long-press, which triggered the delete flow directly. The delete confirmation dialog appeared after the group was already removed.

Changes

  • packages/app/src/components/home/GroupCard.tsx: Added an onContextMenu handler that opens a Rename/Delete context menu on right-click, preventing the default behavior and the immediate delete path.
  • packages/app/src/components/home/HomePage.tsx: Added delete confirmation (window.confirm) before calling removeGroup().
  • packages/app/src/components/layout/Sidebar.tsx: Reworked sidebar group right-click to show a proper context menu with Rename and Delete options, with delete confirmation before removal.

Verification

  • pnpm install --frozen-lockfile
  • npm run build

@codedogQBY codedogQBY left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

中文:
验证 #487 时发现删除确认仍然有问题,需要修改后再合并。

失败场景:

  1. 首页分组卡片:右键打开菜单后点击“删除”,分组会在未点击确认的情况下被删除。预期:必须先弹出确认,并且只有用户明确确认后才调用 removeGroup;取消或未确认时不能删除。
  2. 左侧栏分组 chip:右键打开菜单后点击“删除”,同样会在未点击确认的情况下删除。预期同上。

建议不要依赖当前的删除入口直接继续执行删除逻辑,可以改成项目内已有的确认弹窗/对话框,或确保 removeGroup 只会在确认回调返回 true 后执行。请同时覆盖 GroupCard 和 Sidebar 两个入口。

English:
I tested #487 and the delete confirmation flow is still broken, so this should be fixed before merging.

Failing cases:

  1. Home group card: after opening the context menu and clicking Delete, the group is deleted without an explicit confirmation click. Expected: show a confirmation first, and call removeGroup only after the user explicitly confirms. Cancel/no confirmation must not delete the group.
  2. Sidebar group chip: right-click menu Delete has the same issue. Expected behavior is the same.

Please avoid letting the delete action fall through immediately. Prefer the app's existing confirmation dialog/modal, or otherwise ensure removeGroup is invoked only after the confirmation result is true. Please fix both GroupCard and Sidebar paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Windows端右键分组会直接删除分组

2 participants