Skip to content

Conversation

@JammingBen
Copy link
Contributor

This didn't work before because the event listener for the ctrl/cmd + V shortcut was preventing the default. Adds an option to configure this and disables it for this shortcut.

fixes #1037

This didn't work before because the event listener for the ctrl/cmd + V shortcut was preventing the default. Adds an option to configure this and disables it for this shortcut.
@JammingBen JammingBen self-assigned this Aug 4, 2025
@JammingBen JammingBen marked this pull request as ready for review August 4, 2025 13:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where pasting files from the local system clipboard wasn't working due to the Ctrl/Cmd + V keyboard shortcut preventing the default browser behavior. The fix adds configurable preventDefault option to keyboard actions and disables it specifically for the paste shortcut when no internal clipboard resources are present.

  • Adds optional preventDefault parameter to keyboard action binding system
  • Modifies paste keyboard action to only prevent default when internal clipboard has resources
  • Improves safety checks in clipboard store methods
  • Refactors paste event handling to use Vue's useEventListener composable

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

File Description
packages/web-pkg/src/composables/piniaStores/clipboard.ts Adds optional chaining to prevent errors when accessing empty resource arrays
packages/web-pkg/src/composables/keyboardActions/useKeyboardActions.ts Adds configurable preventDefault option to keyboard action binding
packages/web-app-files/src/composables/keyboardActions/useKeyboardFileSpaceActions.ts Modifies paste action to conditionally prevent default based on clipboard state
packages/web-app-files/src/components/AppBar/CreateAndUpload.vue Refactors paste event listener to use Vue composable and removes manual cleanup

keys: { primary: Key; modifier?: Modifier },
callback: () => void
callback: (event: KeyboardEvent) => void,
{ preventDefault = true }: { preventDefault?: boolean } = {}
Copy link

Copilot AI Aug 4, 2025

Choose a reason for hiding this comment

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

[nitpick] The destructuring parameter with default value should be extracted to a separate parameter for better readability and consistency with the function signature above.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@AlexAndBear AlexAndBear left a comment

Choose a reason for hiding this comment

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

🚀 nice

@AlexAndBear
Copy link
Contributor

@JammingBen or @ScharfViktor is it possible to write an e2e test for this feature ?

@ScharfViktor
Copy link
Contributor

@JammingBen or @ScharfViktor is it possible to write an e2e test for this feature ?

I'll try to create test for that. I hope something like it should work

await page.getByLabel('Upload file').setInputFiles({
  name: 'file.txt',
  mimeType: 'text/plain',
  buffer: Buffer.from('this is test')
})

@JammingBen JammingBen merged commit 58361f4 into main Aug 5, 2025
30 checks passed
@JammingBen JammingBen deleted the fix/paste-from-local-clipboard branch August 5, 2025 07:26
@openclouders openclouders mentioned this pull request Aug 5, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement paste from Clipboard

4 participants