Skip to content

fix: Copy and delete form information #2778

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

Merged
merged 1 commit into from
Apr 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</span>
<span v-if="type == 'ai-chat' || type == 'log'">
<el-tooltip effect="dark" :content="$t('common.copy')" placement="top">
<el-button text @click="copyClick(data?.answer_text.trim())">
<el-button text @click="copy(data)">
<AppIcon iconName="app-copy"></AppIcon>
</el-button>
</el-tooltip>
Expand Down Expand Up @@ -106,7 +106,16 @@ import applicationApi from '@/api/application'
import { datetimeFormat } from '@/utils/time'
import { MsgError } from '@/utils/message'
import bus from '@/bus'

const copy = (data: any) => {
try {
const text = data.answer_text_list
.map((item: Array<any>) => item.map((i) => i.content).join('\n'))
.join('\n\n')
copyClick(text)
} catch (e: any) {
copyClick(removeFormRander(data?.answer_text.trim()))
}
}
const route = useRoute()
const {
params: { id }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an updated version of some TypeScript code for handling button clicks or tooltips. The key changes:

  • The copy function now concatenates multiple answer text components into a single string with line breaks.
  • It handles potential errors gracefully and falls back to removing form renderers if there's an error copying the formatted text.

Additionally, here’s what you might want to check based on the provided information:

  1. Data Types: Ensure data?.answer_text_trim() and removeFormRander(data?.answer_text.trim()) return either a valid string or null/undefined without causing errors when used later.

  2. Functionality Check:

    • Verify that clicking each respective button correctly triggers its intended logic (in this case, copying text).
  3. Event Listeners:

    • Make sure no other parts of your application are trying to listen for these button click events before or after them.
  4. Accessibility:

    • Ensure accessibility features like ARIA attributes are correct and properly implemented for users who rely on screen readers.

Overall, it seems to be functioning well given the current implementation but make sure all data points involved meet expected types and conditions.

Expand Down