Skip to content

Commit

Permalink
chore(useClipboard): rename "type" to "action" in getItems details (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
reidbarber authored Feb 28, 2025
1 parent e8b4bf8 commit e0e86a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions packages/@react-aria/dnd/src/useClipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {useFocus} from '@react-aria/interactions';

export interface ClipboardProps {
/** A function that returns the items to copy. */
getItems?: (details: {type: 'cut' | 'copy'}) => DragItem[],
getItems?: (details: {action: 'cut' | 'copy'}) => DragItem[],
/** Handler that is called when the user triggers a copy interaction. */
onCopy?: () => void,
/** Handler that is called when the user triggers a cut interaction. */
Expand Down Expand Up @@ -88,7 +88,7 @@ export function useClipboard(options: ClipboardProps): ClipboardResult {

e.preventDefault();
if (e.clipboardData) {
writeToDataTransfer(e.clipboardData, options.getItems({type: 'copy'}));
writeToDataTransfer(e.clipboardData, options.getItems({action: 'copy'}));
options.onCopy?.();
}
});
Expand All @@ -106,7 +106,7 @@ export function useClipboard(options: ClipboardProps): ClipboardResult {

e.preventDefault();
if (e.clipboardData) {
writeToDataTransfer(e.clipboardData, options.getItems({type: 'cut'}));
writeToDataTransfer(e.clipboardData, options.getItems({action: 'cut'}));
options.onCut();
}
});
Expand Down
8 changes: 4 additions & 4 deletions packages/@react-aria/dnd/test/useClipboard.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,9 @@ describe('useClipboard', () => {
expect(await onPaste.mock.calls[0][0][1].getText('text/plain')).toBe('item 2');
});

it('should show the type of the clipboard event if cutting', async () => {
it('should show the action type of the clipboard event if cutting', async () => {
let getItems = (details) => [{
[details.type]: 'test data'
[details.action]: 'test data'
}];

let onCut = jest.fn();
Expand All @@ -382,9 +382,9 @@ describe('useClipboard', () => {
expect(onCut).toHaveBeenCalledTimes(1);
});

it('should show the type of the clipboard event if copying', async () => {
it('should show the action type of the clipboard event if copying', async () => {
let getItems = (details) => [{
[details.type]: 'test data'
[details.action]: 'test data'
}];

let onCopy = jest.fn();
Expand Down

1 comment on commit e0e86a9

@rspbot
Copy link

@rspbot rspbot commented on e0e86a9 Feb 28, 2025

Choose a reason for hiding this comment

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

Please sign in to comment.