Skip to content

Commit

Permalink
Add reaction to jsonField to respond to theme changes, Fixes: #507 (#511
Browse files Browse the repository at this point in the history
)

* Add a reaction to jsonField to respond to theme changes

* Minor cleanups
  • Loading branch information
febbraiod authored and lbwexler committed Aug 9, 2018
1 parent 0798f6b commit 5a901ac
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion desktop/cmp/form/JsonField.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ export class JsonField extends HoistField {
editorProps: PT.object
};

constructor() {
super();
this.addReaction({
track: () => XH.darkTheme,
run: () => {
const {editor} = this;
if (editor) editor.setOption('theme', XH.darkTheme ? 'dracula' : 'default');
}
});
}

editor = null;
taCmp = null;

Expand Down Expand Up @@ -143,7 +154,7 @@ export class JsonField extends HoistField {

// CodeMirror docs: If you dynamically create and destroy editors made with `fromTextArea`
// ...you should make sure to call `toTextArea` to remove the editor
componentWillUnmount() {
destroy() {
if (this.editor) this.editor.toTextArea();
}

Expand Down

0 comments on commit 5a901ac

Please sign in to comment.