-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation of Cell Copy/Paste Events Using Clipboard Events #3462
base: main
Are you sure you want to change the base?
Conversation
@@ -198,6 +194,10 @@ A number defining the height of summary rows. | |||
|
|||
###### `onCellKeyDown?: Maybe<(args: CellKeyDownArgs<R, SR>, event: CellKeyboardEvent) => void>` | |||
|
|||
###### `onCopy?: Maybe<(args: CellCopyArgs<R>, event: CellClipboardEvent) => void>` | |||
|
|||
###### `onPaste?: Maybe<(args: CellPasteArgs<R>, event: CellClipboardEvent) => R>` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two things to consider.
- It might be more appropriate to name each handler
onCellCopy
/onCellPaste
onPaste
might not need to returnR
.
However, above changes will be breaking changes for some developers.
I leave them as they are without making any changes for now.
if (cellEvent.isGridDefaultPrevented()) return; | ||
|
||
updateRow(targetColumn, rowIdx, updatedTargetRow); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if developers use event.preventGridDefault()
in onPaste
handler, the default behavior to update the row would be prevented.
if (cellEvent.isGridDefaultPrevented()) return; | ||
|
||
setCopiedCell({ row: sourceRow, columnKey: sourceColumnKey }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if developers use event.preventGridDefault()
in onCopy
handler, the default behavior to set the copied cell internally would be prevented.
Hi, maintainers!
This PR implements onCopy/onPaste events as Cell Clipboard Events not parts of keydown events.
Previously, copy and paste events were implemented as part of keydown events.
This could be slightly confusing for developers. For example,
preventGridDefault
method cannot be used to prevent the default onCopy behavior.With this PR, developers can now utilize Clipboard events, allowing for development with natural APIs without the need to use
navigator.clipboard.writeText
.Additionally, by separating the processes that were aggregated under keydown events into onCopy and onPaste events, it is possible to reduce the complexity of the implementation.
I believe this feature is in high demand among many developers.
I hope you will consider it.
Related PRs
Related issues