Skip to content

Commit

Permalink
fix(clipboard): add warn when message slot not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
aesteves60 authored and dpellier committed Feb 26, 2024
1 parent ec670ab commit 0815fe4
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,16 @@ class OdsClipboardController {

try {
await writeOnClipboard(value);
this.openSurfaceWithMessage(successMessage);
this.openSurfaceWithMessage(successMessage, 'Slot "success-message" is not defined. If you want a tooltip with a success message you need to defined it.');
} catch (error) {
this.openSurfaceWithMessage(errorMessage);
this.openSurfaceWithMessage(errorMessage, 'Slot "error-message" is not defined. If you want a tooltip with a error message you need to defined it.');
throw error;
}
}

private openSurfaceWithMessage(message: string | undefined): void {
private openSurfaceWithMessage(message: string | undefined, warnMessage: string): void {
if (!message || !this.component.surface) {
console.warn(warnMessage);
return;
}
this.component.surfaceMessage = message;
Expand Down

0 comments on commit 0815fe4

Please sign in to comment.