diff --git a/CHANGELOG.md b/CHANGELOG.md index 38c592b350f..eb5a1e85658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## [`master`](https://github.com/elastic/eui/tree/master) -No public interface changes since `17.1.1`. +**Bug fixes** + +- Fixed `EuiCodeEditor` custom mode file error by initializing with existing mode ([#2616](https://github.com/elastic/eui/pull/2616)) ## [`17.1.1`](https://github.com/elastic/eui/tree/v17.1.1) diff --git a/src/components/code_editor/code_editor.js b/src/components/code_editor/code_editor.js index 6cbe07a731e..0f73552cd7a 100644 --- a/src/components/code_editor/code_editor.js +++ b/src/components/code_editor/code_editor.js @@ -6,6 +6,8 @@ import AceEditor from 'react-ace'; import { htmlIdGenerator, keyCodes } from '../../services'; import { EuiI18n } from '../i18n'; +const DEFAULT_MODE = 'text'; + function setOrRemoveAttribute(element, attributeName, value) { if (value === null || value === undefined) { element.removeAttribute(attributeName); @@ -120,6 +122,7 @@ export class EuiCodeEditor extends Component { isReadOnly, setOptions, cursorStart, + mode = DEFAULT_MODE, ...rest } = this.props; @@ -192,10 +195,6 @@ export class EuiCodeEditor extends Component { ); - if (this.isCustomMode()) { - delete rest.mode; // Otherwise, the AceEditor component will complain about wanting a string value for the mode prop. - } - return (