Skip to content

Commit ded9d7c

Browse files
committed
fix(ui): HyperMD editor not properly removed
1 parent 2823353 commit ded9d7c

3 files changed

Lines changed: 41 additions & 6 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
14+
/**
15+
* Removes an element by selector from the DOM.
16+
*
17+
* @param {*} selector A DOMString containing one or more selectors to match.
18+
* @returns {undefined}
19+
*/
20+
const removeElement = (selector) => {
21+
// eslint-disable-next-line no-undef
22+
const element = document.querySelector(selector);
23+
if (element === null) {
24+
// No need to remove something that doesn't exists
25+
return;
26+
}
27+
28+
element.parentNode.removeChild(element);
29+
};
30+
31+
export { removeElement };

lib/public/views/Logs/Create/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ import errorAlert from '../../../components/common/errorAlert.js';
2020
* @param {String} text The text to be set to the preview
2121
* @returns {vnode} returns the preview node
2222
*/
23-
const mdBox = (model, text) => h('', {
24-
onremove: () => model.logs.flushModel(),
25-
}, [
23+
const mdBox = (model, text) => h('', [
2624
h('textarea#text.form-control', {
2725
placeholder: 'Your message...',
2826
disabled: true,
@@ -52,10 +50,12 @@ const createScreen = (model) => {
5250

5351
return h('div#create-log', [
5452
data.isFailure() && data.payload.map(errorAlert),
55-
h('', [
53+
h('', {
54+
onremove: () => model.logs.flushModel(),
55+
}, [
5656
h('h2.mv2', 'Create Log'),
5757
h('h3.black.line-break: auto', 'Title of the log'),
58-
h('input#title', {
58+
h('input#title.w-100', {
5959
placeholder: 'Enter the title of the log entry...',
6060
minlength: 3,
6161
maxlength: 140,
@@ -72,4 +72,4 @@ const createScreen = (model) => {
7272
]);
7373
};
7474

75-
export default (model) => [createScreen(model)];
75+
export default (model) => createScreen(model);

lib/public/views/Logs/Logs.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import { Observable, RemoteData, fetchClient } from '/js/src/index.js';
1515
import { setMarkDownBox } from '../../components/common/markdown.js';
16+
import { removeElement } from '../../utilities/removeElement.js';
1617

1718
/**
1819
* Model representing handlers for homePage.js
@@ -375,6 +376,9 @@ export default class Overview extends Observable {
375376
this.editors = [];
376377
this.collapsedColumns = [];
377378
this.isCollapsed = false;
379+
380+
// Remove trailing CodeMirror div(s)
381+
removeElement('.CodeMirror');
378382
}
379383

380384
/**

0 commit comments

Comments
 (0)