File tree Expand file tree Collapse file tree 2 files changed +11
-14
lines changed
webview-ui/src/components/history Expand file tree Collapse file tree 2 files changed +11
-14
lines changed Original file line number Diff line number Diff line change @@ -13,16 +13,14 @@ export const CopyButton = ({ itemTask }: CopyButtonProps) => {
1313 const { isCopied, copy } = useClipboard ( )
1414 const { t } = useAppTranslation ( )
1515
16- const onCopy = useCallback (
17- ( e : React . MouseEvent ) => {
18- e . stopPropagation ( )
19- const tempDiv = document . createElement ( "div" )
20- tempDiv . innerHTML = itemTask
21- const text = tempDiv . textContent || tempDiv . innerText || ""
22- ! isCopied && copy ( text )
23- } ,
24- [ isCopied , copy , itemTask ] ,
25- )
16+ const onCopy = useCallback (
17+ ( e : React . MouseEvent ) => {
18+ e . stopPropagation ( )
19+ const text = itemTask . replace ( / < s p a n c l a s s = " h i s t o r y - i t e m - h i g h l i g h t " > | < \/ s p a n > / g, "" )
20+ ! isCopied && copy ( text )
21+ } ,
22+ [ isCopied , copy , itemTask ] ,
23+ )
2624
2725 return (
2826 < Button
Original file line number Diff line number Diff line change @@ -107,10 +107,9 @@ describe("HistoryView", () => {
107107 const taskContainer = screen . getByTestId ( "virtuoso-item-1" )
108108 fireEvent . mouseEnter ( taskContainer )
109109 const copyButton = within ( taskContainer ) . getByTestId ( "copy-prompt-button" )
110- fireEvent . click ( copyButton )
111- const taskContent = within ( taskContainer ) . getByTestId ( "task-content" )
112- expect ( navigator . clipboard . writeText ) . toHaveBeenCalledWith ( taskContent . textContent )
113- } )
110+ fireEvent . click ( copyButton )
111+ expect ( navigator . clipboard . writeText ) . toHaveBeenCalledWith ( mockTaskHistory [ 0 ] . task )
112+ } )
114113
115114 it ( "handles sort options correctly" , async ( ) => {
116115 const onDone = jest . fn ( )
You can’t perform that action at this time.
0 commit comments