Skip to content

Commit fa1ac26

Browse files
committed
fix(cdk/clipboard): not working inside fullscreen element (#27456)
Fixes that the clipboard service didn't work when the page is fullscreen. Fixes #27447. (cherry picked from commit 1703c27)
1 parent a9756f7 commit fa1ac26

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/cdk/clipboard/pending-copy.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ export class PendingCopy {
3636
textarea.value = text;
3737
// Making the textarea `readonly` prevents the screen from jumping on iOS Safari (see #25169).
3838
textarea.readOnly = true;
39-
this._document.body.appendChild(textarea);
39+
// The element needs to be inserted into the fullscreen container, if the page
40+
// is in fullscreen mode, otherwise the browser won't execute the copy command.
41+
(this._document.fullscreenElement || this._document.body).appendChild(textarea);
4042
}
4143

4244
/** Finishes copying the text. */

src/dev-app/clipboard/clipboard-demo.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,8 @@
1212
<button
1313
[cdkCopyToClipboard]="value"
1414
[cdkCopyToClipboardAttempts]="attempts">Copy to clipboard via directive</button>
15+
16+
<section>
17+
<label for="testing-area">Testing area</label>
18+
<textarea id="testing-area" cols="30" rows="5"></textarea>
19+
</section>

0 commit comments

Comments
 (0)