Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Ctrl+C/Ctrl+V が効かなくなる問題を修正 #1116

Merged
merged 2 commits into from
Mar 4, 2025

Conversation

sunfish-shogi
Copy link
Owner

@sunfish-shogi sunfish-shogi commented Mar 4, 2025

説明 / Description

#1114

特定の操作をしたときに Ctrl+C (Cmd+C) や Ctrl+V (Cmd+V) が効かなくなる問題への回避策を施す。

チェックリスト / Checklist

  • MUST
    • npm test passed
    • npm run lint was applied without warnings
    • changes of /docs/webapp not included (except release branch)
    • console.log not included (except script file)
  • MUST for Outside Contributor
  • RECOMMENDED (it depends on what you change)
    • unit test added/updated
    • i18n

Summary by CodeRabbit

  • New Features
    • Enhanced keyboard shortcuts for more reliable copy and paste actions.
    • Introduced buttons for copy and paste functionality, improving user interaction.
  • Bug Fixes
    • Resolved issues with clipboard event handling to ensure consistent behavior during copy and paste operations.
  • Improvements
    • Updated visibility control for certain elements to improve rendering efficiency.

@sunfish-shogi sunfish-shogi self-assigned this Mar 4, 2025
Copy link

coderabbitai bot commented Mar 4, 2025

Walkthrough

The changes enhance the copy and paste functionality in the main application component. A new hidden <div> with a ref attribute is introduced, containing buttons that trigger copy and paste actions. The script section now includes a clipboard constant defined with ref(), and methods onCopy and onPaste are implemented to call corresponding store methods. Direct event listeners on the body have been removed, and hotkey installation is now handled in the onMounted lifecycle hook.

Changes

File Change Summary
src/renderer/App.vue • Added ref attribute to main <div> and defined const clipboard = ref();
• Introduced two hidden buttons linked to onCopy and onPaste
• Defined methods onCopy (calls store.copyRecordKIF()) and onPaste (calls store.showPasteDialog())
• Removed direct body event listeners; now installs hotkeys via installHotKeyForMainWindow in the onMounted hook
src/renderer/view/main/ControlPane.vue • Replaced v-show with v-if for visibility control of elements
• Removed multiple instances of data-hotkey="Escape" from buttons

Sequence Diagram(s)

sequenceDiagram
    participant M as Main Component
    participant H as Hotkey Installer
    participant U as User
    participant S as Store

    Note over M: On mounted lifecycle hook
    M->>H: installHotKeyForMainWindow(clipboard)
    Note over M: Hotkeys registered

    U->>M: Triggers copy (keyboard/hidden button)
    M->>S: onCopy() → store.copyRecordKIF()

    U->>M: Triggers paste (keyboard/hidden button)
    M->>S: onPaste() → store.showPasteDialog()
Loading

Suggested labels

bug

Poem

I'm a rabbit hopping through code,
With hidden buttons lighting the node.
Copying records with a swift little skip,
And pasting with a joyful flip.
Changes made, I'm full of cheer –
CodeRabbit smiles, for the end is here! 🐇


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

codecov bot commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.47%. Comparing base (18e2a08) to head (7c041fd).
Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1116   +/-   ##
=======================================
  Coverage   78.47%   78.47%           
=======================================
  Files         122      122           
  Lines       15921    15921           
  Branches     2607     2607           
=======================================
  Hits        12494    12494           
  Misses       3408     3408           
  Partials       19       19           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sunfish-shogi sunfish-shogi force-pushed the fix-copy-paste-issue branch from 0c963b7 to 7c041fd Compare March 4, 2025 14:07
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/renderer/view/main/ControlPane.vue (2)

5-5: Changed rendering directive from v-show to v-if

The change from v-show to v-if affects how this control group is handled in the DOM. With v-if, the element is completely removed from the DOM when the condition is false, rather than just being hidden with CSS (v-show).

This change likely helps with the Ctrl+C/Ctrl+V issue by reducing DOM complexity when elements aren't needed, but consider documenting this architectural decision in a comment to explain why v-if is preferred over v-show in this case.


170-170: Changed rendering directive from v-show to v-if

Similar to the previous change, switching from v-show to v-if for the second control group changes its DOM behavior.

This is consistent with the change made to the first control group. Both changes together help streamline the DOM structure when certain controls aren't needed, which can improve event handling for keyboard shortcuts.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0c963b7 and 7c041fd.

📒 Files selected for processing (2)
  • src/renderer/App.vue (2 hunks)
  • src/renderer/view/main/ControlPane.vue (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (6)
src/renderer/App.vue (6)

55-60: Added workaround for clipboard operation issue

The implementation adds hidden buttons with hotkey attributes to handle copy/paste operations, addressing the issue mentioned in the comments where normal copy/paste events weren't being captured properly.

This is a good workaround for the copy/paste functionality issue. The comments clearly explain the problem and reference the related issue #1114. The hidden div with buttons provides a clean way to capture keyboard shortcuts without affecting the UI.


65-65: Added ref import from Vue

Added ref to the import list from Vue to support the clipboard reference.


105-105: Added clipboard reference

Created a reference to connect with the hidden div in the template.

The reference is properly defined and will be used to install hotkeys for the clipboard operations.


113-119: Implemented copy and paste handlers

Added functions to handle copy and paste actions by calling appropriate store methods.

The implementation is clean and straightforward. onCopy calls store.copyRecordKIF() and onPaste calls store.showPasteDialog(), which appear to be the correct operations for these actions.


122-122: Updated hotkey installation

Modified the onMounted hook to install hotkeys for the main window using the clipboard reference.

The hotkey installation is correctly placed in the onMounted lifecycle hook to ensure it's set up when the component is mounted. Using the clipboard reference connects it to the hidden buttons added in the template.


55-122:

❓ Verification inconclusive

Verify the clipboard functionality works across different platforms

The implementation uses the Mod+C and Mod+V shortcuts, which should translate to Ctrl+C/Ctrl+V on Windows/Linux and Cmd+C/Cmd+V on macOS.

Since the PR specifically mentions fixing an issue where Ctrl+C/Ctrl+V don't work, it's important to verify this fix works properly across different operating systems and browsers. Consider testing the following:

  1. Does it work on Windows, macOS, and Linux?
  2. Does it work in different browsers if this is a web application?
  3. Are there any edge cases where the clipboard operations might still fail?

🏁 Script executed:

#!/bin/bash
# Check if the hotkey module properly handles platform-specific key bindings

# Look for platform-specific code in the hotkey implementation
rg -A 10 "platform|os|mac|windows|linux" src/renderer/devices/hotkey.ts

Length of output: 73


Action Required: Cross-Platform Clipboard Shortcut Verification

The current implementation sets up clipboard event handling through installHotKeyForMainWindow(clipboard.value) using the Mod+c and Mod+v shortcuts. As these should translate to Ctrl+C/Ctrl+V on Windows/Linux and Cmd+C/Cmd+V on macOS, please ensure through manual testing that:

  • The clipboard functionality behaves correctly on Windows, macOS, and Linux.
  • In case this is used in a web context, verify the behavior in all supported browsers.
  • Any potential edge cases (e.g., alternative input methods or unexpected focus behavior) are handled properly.

Since the recent automated code search for platform-specific key handling in the hotkey module did not return any results, a detailed manual test across environments is recommended to confirm that the current implementation meets the intended cross-platform requirements.

@sunfish-shogi sunfish-shogi merged commit 7076153 into main Mar 4, 2025
5 checks passed
@sunfish-shogi sunfish-shogi deleted the fix-copy-paste-issue branch March 4, 2025 14:19
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant