Skip to content

Commit e441f05

Browse files
authored
Disable code copy buttons for now in copilot search for a11y (#57331)
1 parent 2de13b5 commit e441f05

File tree

3 files changed

+7
-21
lines changed

3 files changed

+7
-21
lines changed

data/ui.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ search:
6363
invalid_query: Sorry, I'm unable to answer that question. Please try asking a different question.
6464
response:
6565
copy_code: Copy code to clipboard
66-
copy_code_lang: Copy {language} code to clipboard, block {block}
66+
copy_code_lang: Copy {language} code to clipboard
6767
copied_code: Copied!
6868
failure:
6969
general_title: There was an error loading search results.

src/fixtures/fixtures/data/ui.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ search:
6363
invalid_query: Sorry, I'm unable to answer that question. Please try asking a different question.
6464
response:
6565
copy_code: Copy code to clipboard
66-
copy_code_lang: Copy {language} code to clipboard, block {block}
66+
copy_code_lang: Copy {language} code to clipboard
6767
copied_code: Copied!
6868
failure:
6969
general_title: There was an error loading search results.

src/frame/components/ui/MarkdownContent/UnrenderedMarkdownContent.tsx

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,6 @@ import useCopyClipboard from '@/rest/components/useClipboard'
1212
import { EventType } from '@/events/types'
1313
import { sendEvent } from '@/events/components/events'
1414

15-
// Create a unique identifier by sampling characters distributed across content
16-
function getBlockId(text: string, targetLength: number = 8) {
17-
const alphanumeric = text.replace(/[^a-zA-Z0-9]+/g, '').toLowerCase()
18-
if (!alphanumeric || alphanumeric.length <= targetLength) {
19-
return Math.random().toString(36).substring(2, 10)
20-
}
21-
const step = alphanumeric.length / targetLength
22-
let result = ''
23-
for (let i = 0; i < targetLength; i++) {
24-
const index = Math.floor(i * step)
25-
result += alphanumeric[index]
26-
}
27-
return result
28-
}
29-
3015
export type MarkdownContentPropsT = {
3116
children: string
3217
className?: string
@@ -44,7 +29,7 @@ export const UnrenderedMarkdownContent = ({
4429
className,
4530
openLinksInNewTab = true,
4631
includeQueryParams = true,
47-
codeBlocksCopyable = true,
32+
codeBlocksCopyable = false,
4833
eventGroupKey = '',
4934
eventGroupId = '',
5035
...restProps
@@ -80,9 +65,10 @@ export const UnrenderedMarkdownContent = ({
8065
if (isCopied) {
8166
return t('search.ai.response.copied_code')
8267
}
83-
return t('search.ai.response.copy_code_lang')
84-
.replace('{language}', language ? `${language} ` : '')
85-
.replace('{block}', getBlockId(text))
68+
return t('search.ai.response.copy_code_lang').replace(
69+
'{language}',
70+
language ? `${language} ` : '',
71+
)
8672
}
8773

8874
return (

0 commit comments

Comments
 (0)