From 1a985f95f56da1f9ebefdb26d3f1ead89439de01 Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Mon, 1 Jun 2020 18:44:21 +0200 Subject: [PATCH] feat: initialise editor with 'first' file Since sort-files exists, the challengeFiles have an order. The editor now displays the first file on mount. --- client/src/templates/Challenges/classic/Editor.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/templates/Challenges/classic/Editor.js b/client/src/templates/Challenges/classic/Editor.js index 3b973a89e4..c3b0416906 100644 --- a/client/src/templates/Challenges/classic/Editor.js +++ b/client/src/templates/Challenges/classic/Editor.js @@ -14,6 +14,7 @@ import { } from '../redux'; import { userSelector, isDonationModalOpenSelector } from '../../../redux'; import { Loader } from '../../../components/helpers'; +import { sortFiles } from '../utils/sort-files'; import './editor.css'; @@ -129,10 +130,11 @@ class Editor extends Component { } }; + const { challengeFiles } = this.props; + // NOTE: for consitency with this.data (and this.options) currentFileKey // is just a property, not state. - - this.currentFileKey = 'indexhtml'; + this.currentFileKey = sortFiles(challengeFiles)[0].key; this.options = { fontSize: '18px',