diff --git a/packages/core/chrome/core-chrome-browser-internal/src/chrome_service.tsx b/packages/core/chrome/core-chrome-browser-internal/src/chrome_service.tsx index 380314554dedd..5f9a17713861c 100644 --- a/packages/core/chrome/core-chrome-browser-internal/src/chrome_service.tsx +++ b/packages/core/chrome/core-chrome-browser-internal/src/chrome_service.tsx @@ -11,6 +11,7 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { BehaviorSubject, combineLatest, merge, type Observable, of, ReplaySubject } from 'rxjs'; import { mergeMap, map, takeUntil, filter } from 'rxjs'; import { parse } from 'url'; +import { setEuiDevProviderWarning } from '@elastic/eui'; import useObservable from 'react-use/lib/useObservable'; import type { CoreContext } from '@kbn/core-base-browser-internal'; @@ -173,6 +174,39 @@ export class ChromeService { this.mutationObserver.observe(body, { attributes: true }); }; + // Ensure developers are notified if working in a context that lacks the EUI Provider. + private handleEuiDevProviderWarning = (notifications: NotificationsStart) => { + const isDev = this.params.coreContext.env.mode.name === 'development'; + if (isDev) { + setEuiDevProviderWarning((providerError) => { + const errorObject = new Error(providerError.toString()); + // show a stack trace in the console + // eslint-disable-next-line no-console + console.error(errorObject); + + notifications.toasts.addDanger({ + title: '`EuiProvider` is missing', + text: mountReactNode( +
+