Fix copy cotent and stop click propagation

pull/4504/head
ioedeveloper 9 months ago committed by Aniket
parent e87db8bf44
commit 24416dcc55
  1. 4
      apps/circuit-compiler/src/app/components/feedback.tsx
  2. 10
      apps/circuit-compiler/src/app/components/feedbackAlert.tsx
  3. 1
      apps/circuit-compiler/src/app/types/index.ts
  4. 1
      libs/remix-ui/clipboard/src/lib/copy-to-clipboard/copy-to-clipboard.tsx

@ -45,8 +45,7 @@ export function CompilerFeedback ({ feedback, filePathToId, hideWarnings, openEr
<RenderIf condition={response.type === 'Error'}> <RenderIf condition={response.type === 'Error'}>
<div className={`circuit_feedback ${response.type.toLowerCase()} alert alert-danger`} data-id="circuit_feedback"> <div className={`circuit_feedback ${response.type.toLowerCase()} alert alert-danger`} data-id="circuit_feedback">
<FeedbackAlert <FeedbackAlert
message={response.message} message={response.message + (response.labels[0] ? ": " + response.labels[0].message + ` ${filePathToId[response.labels[0].file_id]}:${response.labels[0].range.start}:${response.labels[0].range.end}` : '')}
location={ response.labels[0] ? response.labels[0].message + ` ${filePathToId[response.labels[0].file_id]}:${response.labels[0].range.start}:${response.labels[0].range.end}` : null}
askGPT={ () => handleAskGPT(response) } /> askGPT={ () => handleAskGPT(response) } />
</div> </div>
</RenderIf> </RenderIf>
@ -54,7 +53,6 @@ export function CompilerFeedback ({ feedback, filePathToId, hideWarnings, openEr
<div className={`circuit_feedback ${response.type.toLowerCase()} alert alert-warning`} data-id="circuit_feedback"> <div className={`circuit_feedback ${response.type.toLowerCase()} alert alert-warning`} data-id="circuit_feedback">
<FeedbackAlert <FeedbackAlert
message={response.message} message={response.message}
location={null}
askGPT={() => { handleAskGPT(response) }} /> askGPT={() => { handleAskGPT(response) }} />
</div> </div>
</RenderIf> </RenderIf>

@ -3,7 +3,7 @@ import { FeedbackAlertProps } from '../types'
import { RenderIf } from '@remix-ui/helper' import { RenderIf } from '@remix-ui/helper'
import {CopyToClipboard} from '@remix-ui/clipboard' import {CopyToClipboard} from '@remix-ui/clipboard'
export function FeedbackAlert ({ message, location, askGPT }: FeedbackAlertProps) { export function FeedbackAlert ({ message, askGPT }: FeedbackAlertProps) {
const [ showAlert, setShowAlert] = useState<boolean>(true) const [ showAlert, setShowAlert] = useState<boolean>(true)
const handleCloseAlert = () => { const handleCloseAlert = () => {
@ -14,9 +14,6 @@ export function FeedbackAlert ({ message, location, askGPT }: FeedbackAlertProps
<RenderIf condition={showAlert}> <RenderIf condition={showAlert}>
<> <>
<span> { message } </span> <span> { message } </span>
<RenderIf condition={location !== null}>
<span> { location }</span>
</RenderIf>
<div className="close" data-id="renderer" onClick={handleCloseAlert}> <div className="close" data-id="renderer" onClick={handleCloseAlert}>
<i className="fas fa-times"></i> <i className="fas fa-times"></i>
</div> </div>
@ -24,7 +21,10 @@ export function FeedbackAlert ({ message, location, askGPT }: FeedbackAlertProps
<span className="ml-3 pt-1 py-1" > <span className="ml-3 pt-1 py-1" >
<CopyToClipboard content={message} className="p-0 m-0 far fa-copy error" direction={'top'} /> <CopyToClipboard content={message} className="p-0 m-0 far fa-copy error" direction={'top'} />
</span> </span>
<span className="border border-success text-success btn-sm" onClick={askGPT}>ASK GPT</span> <span className="border border-success text-success btn-sm" onClick={(e) => {
e.stopPropagation()
askGPT()
}}>ASK GPT</span>
</div> </div>
</> </>
</RenderIf> </RenderIf>

@ -72,7 +72,6 @@ export type CompilerReport = {
export type FeedbackAlertProps = { export type FeedbackAlertProps = {
message: string, message: string,
location: string,
askGPT: () => void askGPT: () => void
} }

@ -44,6 +44,7 @@ export const CopyToClipboard = (props: ICopyToClipboard) => {
content = getContent && getContent() content = getContent && getContent()
copyData() copyData()
} }
e.stopPropagation()
e.preventDefault() e.preventDefault()
} }

Loading…
Cancel
Save