From add6a432c23c97123fce0770a9bb3f7ab71180dd Mon Sep 17 00:00:00 2001 From: Akshat Patel Date: Wed, 8 May 2024 18:45:13 -0400 Subject: [PATCH 1/2] fix: copy inner text or text content of code element Signed-off-by: Akshat Patel --- src/code-snippet/code-snippet.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/code-snippet/code-snippet.component.ts b/src/code-snippet/code-snippet.component.ts index 50e8f3fc12..21cce3b540 100644 --- a/src/code-snippet/code-snippet.component.ts +++ b/src/code-snippet/code-snippet.component.ts @@ -269,7 +269,7 @@ export class CodeSnippet extends BaseIconButton implements OnInit, AfterViewInit onCopyButtonClicked() { if (!this.disabled) { window.navigator.clipboard - .writeText(this.code).then(() => { + .writeText(this.code.nativeElement.innerText || this.code.nativeElement.textContent).then(() => { this.showFeedback = true; this.animating = true; setTimeout(() => { From 2b2b05946e1dd30be9aa63a6c18e65cec06137b3 Mon Sep 17 00:00:00 2001 From: Akshat Patel Date: Wed, 8 May 2024 18:46:12 -0400 Subject: [PATCH 2/2] docs: rename argument since storybook creates args in global scope which is referenced by component Signed-off-by: Akshat Patel --- src/code-snippet/code-snippet.stories.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/code-snippet/code-snippet.stories.ts b/src/code-snippet/code-snippet.stories.ts index e7df0a77d6..2e529ce8ed 100644 --- a/src/code-snippet/code-snippet.stories.ts +++ b/src/code-snippet/code-snippet.stories.ts @@ -11,7 +11,7 @@ export default { }) ], argTypes: { - code: { + snippet: { control: false }, display: { @@ -42,34 +42,34 @@ export default { const Template = (args) => ({ props: args, template: ` - {{code}} + {{snippet}} ` }); export const Basic = Template.bind({}); Basic.args = { - code: `import { UIShellModule } from 'carbon-components-angular'; // Single line of code` + snippet: `import { UIShellModule } from 'carbon-components-angular'; // Single line of code` }; const InlineTemplate = (args) => ({ props: args, template: ` - Here is some {{code}} for you. + Here is some {{snippet}} for you. ` }); export const Inline = InlineTemplate.bind({}); Inline.args = { - code: "" + snippet: "" }; const MultiTemplate = (args) => ({ props: args, template: ` - {{code}} + {{snippet}} ` }); export const Multi = MultiTemplate.bind({}); Multi.args = { - code: `{ + snippet: `{ "name": "carbon-components-angular", "version": "0.0.0", "description": "Next generation components",