Skip to content

Commit 1a2befa

Browse files
crisbetommalerba
authored andcommitted
fix(clipboard): namespace copied output name (#17598)
Since the `cdkCopyToClipboard` is a directive that uses an element selector, the name of the `copied` output needs to be namespaced. Since the API is already released, these changes deprecate the unprefixed version and add a prefixed one.
1 parent 39c0074 commit 1a2befa

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/cdk/clipboard/copy-to-clipboard.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ const COPY_CONTENT = 'copy content';
88

99
@Component({
1010
selector: 'copy-to-clipboard-host',
11-
template: `<button [cdkCopyToClipboard]="content" (copied)="copied.emit($event)"></button>`,
11+
template: `
12+
<button
13+
[cdkCopyToClipboard]="content"
14+
(cdkCopyToClipboardCopied)="copied.emit($event)"></button>`,
1215
})
1316
class CopyToClipboardHost {
1417
@Input() content = '';

src/cdk/clipboard/copy-to-clipboard.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,15 @@ export class CdkCopyToClipboard {
2828
* Emits when some text is copied to the clipboard. The
2929
* emitted value indicates whether copying was successful.
3030
*/
31-
@Output() copied = new EventEmitter<boolean>();
31+
@Output('cdkCopyToClipboardCopied') copied = new EventEmitter<boolean>();
32+
33+
/**
34+
* Emits when some text is copied to the clipboard. The
35+
* emitted value indicates whether copying was successful.
36+
* @deprecated Use `cdkCopyToClipboardCopied` instead.
37+
* @breaking-change 10.0.0
38+
*/
39+
@Output('copied') _deprecatedCopied = this.copied;
3240

3341
constructor(private readonly _clipboard: Clipboard) {}
3442

tools/public_api_guard/cdk/clipboard.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export declare class CdkCopyToClipboard {
2+
_deprecatedCopied: EventEmitter<boolean>;
23
copied: EventEmitter<boolean>;
34
text: string;
45
constructor(_clipboard: Clipboard);

0 commit comments

Comments
 (0)