From 626c42e91be50f94d3c4259f2f534bbe1c8eda66 Mon Sep 17 00:00:00 2001
From: Alexey Antonov
Date: Mon, 11 May 2020 13:10:07 +0300
Subject: [PATCH 1/2] [EuiCodeEditor] Console error when using the editor
without importing the default theme
---
.../code_editor/__snapshots__/code_editor.test.tsx.snap | 8 ++++----
src/components/code_editor/code_editor.tsx | 5 ++++-
2 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/src/components/code_editor/__snapshots__/code_editor.test.tsx.snap b/src/components/code_editor/__snapshots__/code_editor.test.tsx.snap
index bb4c16c2d92..a2b499f3552 100644
--- a/src/components/code_editor/__snapshots__/code_editor.test.tsx.snap
+++ b/src/components/code_editor/__snapshots__/code_editor.test.tsx.snap
@@ -87,7 +87,7 @@ exports[`EuiCodeEditor is rendered 1`] = `
@@ -203,7 +203,7 @@ exports[`EuiCodeEditor props aria attributes allows setting aria-describedby on
@@ -319,7 +319,7 @@ exports[`EuiCodeEditor props aria attributes allows setting aria-labelledby on t
@@ -435,7 +435,7 @@ exports[`EuiCodeEditor props isReadOnly renders alternate hint text 1`] = `
diff --git a/src/components/code_editor/code_editor.tsx b/src/components/code_editor/code_editor.tsx
index c7fa69d1a4d..1d25c9e8cc8 100644
--- a/src/components/code_editor/code_editor.tsx
+++ b/src/components/code_editor/code_editor.tsx
@@ -25,7 +25,10 @@ import { keysOf } from '../common';
import { htmlIdGenerator, keyCodes } from '../../services';
import { EuiI18n } from '../i18n';
+import 'brace/theme/github';
+
const DEFAULT_MODE = 'text';
+const DEFAULT_THEME = 'github';
function setOrRemoveAttribute(
element: HTMLTextAreaElement,
@@ -215,7 +218,7 @@ export class EuiCodeEditor extends Component<
cursorStart,
mode = DEFAULT_MODE,
'data-test-subj': dataTestSubj = 'codeEditorContainer',
- theme = 'github',
+ theme = DEFAULT_THEME,
...rest
} = this.props;
From 70210258736c3649d2d5f4b0ccbb8b19bf8c9b85 Mon Sep 17 00:00:00 2001
From: Alexey Antonov
Date: Tue, 12 May 2020 13:10:12 +0300
Subject: [PATCH 2/2] set textmate as a default schema
---
CHANGELOG.md | 1 +
.../code_editor/__snapshots__/code_editor.test.tsx.snap | 8 ++++----
src/components/code_editor/code_editor.tsx | 4 +---
3 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1a4bc7170df..28797bffef2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
- Added `utcOffset` prop to `EuiSuperDatePicker` ([#3436](https://github.com/elastic/eui/pull/3436))
- Added `partition` key to `EuiChartThemeType` for Partition chart support ([#3387](https://github.com/elastic/eui/pull/3387))
- Updated `EuiImage`'s `caption` prop type from `string` to `ReactNode` ([#3387](https://github.com/elastic/eui/pull/3387))
+- Fixed `EuiCodeEditor` console error when using the editor without import the default theme ([#3454](https://github.com/elastic/eui/pull/3454))
**Bug Fixes**
diff --git a/src/components/code_editor/__snapshots__/code_editor.test.tsx.snap b/src/components/code_editor/__snapshots__/code_editor.test.tsx.snap
index a2b499f3552..bb4c16c2d92 100644
--- a/src/components/code_editor/__snapshots__/code_editor.test.tsx.snap
+++ b/src/components/code_editor/__snapshots__/code_editor.test.tsx.snap
@@ -87,7 +87,7 @@ exports[`EuiCodeEditor is rendered 1`] = `
@@ -203,7 +203,7 @@ exports[`EuiCodeEditor props aria attributes allows setting aria-describedby on
@@ -319,7 +319,7 @@ exports[`EuiCodeEditor props aria attributes allows setting aria-labelledby on t
@@ -435,7 +435,7 @@ exports[`EuiCodeEditor props isReadOnly renders alternate hint text 1`] = `
diff --git a/src/components/code_editor/code_editor.tsx b/src/components/code_editor/code_editor.tsx
index 1d25c9e8cc8..fb3da63061e 100644
--- a/src/components/code_editor/code_editor.tsx
+++ b/src/components/code_editor/code_editor.tsx
@@ -25,10 +25,8 @@ import { keysOf } from '../common';
import { htmlIdGenerator, keyCodes } from '../../services';
import { EuiI18n } from '../i18n';
-import 'brace/theme/github';
-
const DEFAULT_MODE = 'text';
-const DEFAULT_THEME = 'github';
+const DEFAULT_THEME = 'textmate';
function setOrRemoveAttribute(
element: HTMLTextAreaElement,