Skip to content

Commit

Permalink
fix(clipboard): fix tooltip close delay
Browse files Browse the repository at this point in the history
  • Loading branch information
manoncarbonnel authored and dpellier committed Mar 12, 2024
1 parent f556680 commit 2849fb0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class OdsClipboardController {
}
this.component.surfaceMessage = html;
this.component.surface.opened = !this.component.surface.opened;

setTimeout(() => this.closeSurface(), 3000);
}

getTextContent(html: string): string | null {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,20 @@ describe('e2e:osds-clipboard', () => {
expect(clipboardSurface).toHaveClass('ocdk-surface--open');
});

it('should hide the surface after 3 seconds', async() => {
const value = 'text to copy';
const messages = '<span slot=\'success-message\'>Copied</span><span slot=\'error-message\'>Error</span>';

await setup({ attributes: { value }, html: messages });

await input.click();
expect(clipboardSurface).toHaveClass('ocdk-surface--open');

new Promise((resolve) => setTimeout(resolve, 3000)).then(() => {
expect(clipboardSurface).not.toHaveClass('ocdk-surface--open');
});
});

it('should hide the surface when a click happened outside of the surface', async() => {
const value = 'text to copy';
const messages = '<span slot=\'success-message\'>Copied</span><span slot=\'error-message\'>Error</span>';
Expand Down

0 comments on commit 2849fb0

Please sign in to comment.