{errors[0].longMessage as React.ReactNode}
- {showMore && !canFixInLens ? ( +{getLongMessage(firstError)}
+ {errors.length > 1 && !canFixInLens ? (
{shortMessage}
- {messageGroup.map(({ longMessage }, i) => (
-
diff --git a/x-pack/plugins/lens/public/types.ts b/x-pack/plugins/lens/public/types.ts
index f4063747e9b77..d22016f75620a 100644
--- a/x-pack/plugins/lens/public/types.ts
+++ b/x-pack/plugins/lens/public/types.ts
@@ -302,7 +302,7 @@ export interface UserMessage {
severity: 'error' | 'warning' | 'info';
hidePopoverIcon?: boolean;
shortMessage: string;
- longMessage: string | React.ReactNode | ((closePopover: () => void) => React.ReactNode);
+ longMessage: string | React.ReactNode | ((closePopover?: () => void) => React.ReactNode);
fixableInEditor: boolean;
displayLocations: UserMessageDisplayLocation[];
}
diff --git a/x-pack/plugins/lens/public/user_messages_utils.ts b/x-pack/plugins/lens/public/user_messages_utils.ts
new file mode 100644
index 0000000000000..9a0a7e2425dc9
--- /dev/null
+++ b/x-pack/plugins/lens/public/user_messages_utils.ts
@@ -0,0 +1,12 @@
+/*
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
+ * or more contributor license agreements. Licensed under the Elastic License
+ * 2.0; you may not use this file except in compliance with the Elastic License
+ * 2.0.
+ */
+
+import { UserMessage } from './types';
+
+export function getLongMessage(msg: UserMessage) {
+ return typeof msg.longMessage === 'function' ? msg.longMessage() : msg.longMessage;
+}