mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[ACS-4051] Copy to clipboard button is now accessible through the keyboard enter earlier which was only accessible through mouse click (#8119)
* 880196 CSV issue addressed * unit test cases for clipboard directive
This commit is contained in:
parent
db38ccda7a
commit
067d4e9369
@ -64,6 +64,14 @@ describe('ClipboardDirective', () => {
|
||||
|
||||
expect(clipboardService.copyToClipboard).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should notify copy target value on mouse enter event', () => {
|
||||
spyOn(clipboardService, 'copyToClipboard');
|
||||
fixture.nativeElement.querySelector('input').value = 'some value';
|
||||
window.dispatchEvent(new KeyboardEvent('keydown', {code: 'Enter', key: 'Enter'}));
|
||||
|
||||
expect(clipboardService.copyToClipboard).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('CopyClipboardDirective', () => {
|
||||
@ -128,6 +136,15 @@ describe('CopyClipboardDirective', () => {
|
||||
expect(navigator.clipboard.writeText).toHaveBeenCalledWith('text to copy');
|
||||
}));
|
||||
|
||||
it('should copy the content of element on mouse enter', fakeAsync(() => {
|
||||
fixture.detectChanges();
|
||||
spyOn(navigator.clipboard, 'writeText');
|
||||
window.dispatchEvent(new KeyboardEvent('keydown', {code: 'Enter', key: 'Enter'}));
|
||||
tick();
|
||||
fixture.detectChanges();
|
||||
expect(navigator.clipboard.writeText).toHaveBeenCalledWith('text to copy');
|
||||
}));
|
||||
|
||||
it('should not copy the content of element when click it', fakeAsync(() => {
|
||||
const spanHTMLElement = element.querySelector<HTMLInputElement>('span');
|
||||
fixture.detectChanges();
|
||||
|
@ -46,6 +46,12 @@ export class ClipboardDirective {
|
||||
event.stopPropagation();
|
||||
this.copyToClipboard();
|
||||
}
|
||||
@HostListener('window:keydown.enter', ['$event'])
|
||||
handleKeyDown(event: KeyboardEvent){
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
this.copyToClipboard();
|
||||
}
|
||||
|
||||
@HostListener('mouseenter')
|
||||
showTooltip() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user