From da588181989afb4bee473cd94073fe69f959ba16 Mon Sep 17 00:00:00 2001 From: Yamboy1 Date: Sat, 18 Jan 2020 20:30:35 +1300 Subject: [PATCH] Update codemirror theme when global theme changes --- ui/component/viewers/codeViewer.jsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ui/component/viewers/codeViewer.jsx b/ui/component/viewers/codeViewer.jsx index 3f053b208..4b3f7f740 100644 --- a/ui/component/viewers/codeViewer.jsx +++ b/ui/component/viewers/codeViewer.jsx @@ -31,6 +31,14 @@ class CodeViewer extends React.PureComponent { this.codeMirror = null; } + componentDidUpdate(prevProps: Props): * { + if (prevProps.theme === this.props.theme) return; + + // This code is duplicated with componentDidMount + const theme = this.props.theme === 'dark' ? 'monokai' : 'default'; + this.codeMirror.setOption('theme', theme); + } + componentDidMount() { const me = this; const { theme, contentType } = me.props;