mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[ACS-10319] SR: Personal files: Focus returns to input field instead of remaining on Copy link button (#11272)
This commit is contained in:
@@ -47,15 +47,11 @@ describe('ClipboardService', () => {
|
|||||||
|
|
||||||
it('should copy text to clipboard', () => {
|
it('should copy text to clipboard', () => {
|
||||||
spyOn(navigator.clipboard, 'writeText');
|
spyOn(navigator.clipboard, 'writeText');
|
||||||
spyOn(inputElement, 'select');
|
|
||||||
spyOn(inputElement, 'setSelectionRange');
|
|
||||||
|
|
||||||
inputElement.value = 'some text';
|
inputElement.value = 'some text';
|
||||||
|
|
||||||
clipboardService.copyToClipboard(inputElement);
|
clipboardService.copyToClipboard(inputElement);
|
||||||
|
|
||||||
expect(inputElement.select).toHaveBeenCalledWith();
|
|
||||||
expect(inputElement.setSelectionRange).toHaveBeenCalledWith(0, inputElement.value.length);
|
|
||||||
expect(navigator.clipboard.writeText).toHaveBeenCalledWith('some text');
|
expect(navigator.clipboard.writeText).toHaveBeenCalledWith('some text');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -45,8 +45,6 @@ export class ClipboardService {
|
|||||||
copyToClipboard(target: HTMLInputElement | HTMLTextAreaElement, message?: string) {
|
copyToClipboard(target: HTMLInputElement | HTMLTextAreaElement, message?: string) {
|
||||||
if (this.isTargetValid(target)) {
|
if (this.isTargetValid(target)) {
|
||||||
try {
|
try {
|
||||||
target.select();
|
|
||||||
target.setSelectionRange(0, target.value.length);
|
|
||||||
if (navigator.clipboard) {
|
if (navigator.clipboard) {
|
||||||
navigator.clipboard.writeText(target.value);
|
navigator.clipboard.writeText(target.value);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user