# JSsidebar generated html

**URL:** https://forum.collaboraonline.com/t/jssidebar-generated-html/1332
**Category:** Development
**Created:** [September 2, 2022, 11:23am UTC](https://forum.collaboraonline.com/t/jssidebar-generated-html/1332 "2022-09-02T11:23:39Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![pedro.silva](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.collaboraonline.com/pedro.silva/32/4_2.png) [@pedro.silva](https://forum.collaboraonline.com/u/pedro.silva)
#### Post date: [September 2, 2022, 11:23am UTC](https://forum.collaboraonline.com/t/jssidebar-generated-html/1332/1 "2022-09-02T11:23:40Z")

</div>

Hi,  
When attempting to fix various problems on the sidebar (by turning elements into flex [GitHub - CollaboraOnline/online at private/pedro/jssidebar-fix-use-cssclasses](https://github.com/CollaboraOnline/online/tree/private/pedro/jssidebar-fix-use-cssclasses) and failed to avoid the need for special cases) I discovered that wouldn’t solve it and led me to conclude that we would greatly benefit from having a simpler generated html structure, more flexible and easier to maintain. As recommended by @szyklos I’m pasting this somewhere before it gets lost/forgotten.

Note: I’m not talking about the JSON that comes from core side (vcl/jsdialog/jsdialogbuilder.cxx). What I’m referring to is the conversion from that to HTML elements that happens on online:JS side. Currently using a mix of Tables, Divs, etc. (browser/src/control/Control.JSDialogBuilder.js)

Main goals:

- Have no need for hard coded corners cases (be that on the JS or CSS side)
  - And related bugs

- Reduce the number of HTML elements we are creating and all the code around to access their children

I didn’t manage to further this, but it seems **\_gridHandler** on Control.JSDialogBuilder.js would be a nice spot to try this out.

Here is a minimal proof of concept using CSS grid layout:

```xml
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="testgrid.css">
  </head>
  <body>
    <div id="app"></div>
	<script src="testgrid.js"></script>
  </body>
</html>

```

```javascript
/* testgrid.js */
var appEl = document.getElementById('app');
/* Easy to set number of rows and number of columns
just by setting the grid-template */
var rowT = 6;
var colT = 2;
var cellT = rowT + colT

var gridEl = '<div class="grid" style=" \
				grid-template-rows: repeat(' + rowT + ', auto); \
				grid-template-columns: repeat(' + colT + ', auto); ">';

for (var i = 0; i < cellT; i++) {
	gridEl += '<div class="cell">cell ' + i + '</div>';
}

gridEl += '</div>';
appEl.insertAdjacentHTML('afterend', gridEl);

```

```css
/* testgrid.css */
.grid {
  display: grid;
}

.cell {
  border: 1px solid #000;
  padding: 10px;
}

```

---

<div class="post-metadata">

### Author: ![szyklos](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.collaboraonline.com/szyklos/32/359_2.png) [@szyklos](https://forum.collaboraonline.com/u/szyklos)
#### Post date: [September 15, 2022, 1:48pm UTC](https://forum.collaboraonline.com/t/jssidebar-generated-html/1332/2 "2022-09-15T13:48:00Z")

</div>

Hi, I’ve just pushed demo PR of CSS Grid for sidebar and dialogs:

> <https://github.com/CollaboraOnline/online/pull/5256>
>
> This is PR which introduces CSS grid to the jsdialogs instead of old table desig…n.
> It should be polished before merge.

It requires more work with alignments, but works pretty good.

---

<div class="post-metadata">

### Author: ![pedro.silva](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.collaboraonline.com/pedro.silva/32/4_2.png) [@pedro.silva](https://forum.collaboraonline.com/u/pedro.silva)
#### Post date: [September 20, 2022, 2:57pm UTC](https://forum.collaboraonline.com/t/jssidebar-generated-html/1332/3 "2022-09-20T14:57:00Z")

</div>



---

<div class="post-metadata">

### Author: ![szyklos](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.collaboraonline.com/szyklos/32/359_2.png) [@szyklos](https://forum.collaboraonline.com/u/szyklos)
#### Post date: [October 14, 2022, 7:39pm UTC](https://forum.collaboraonline.com/t/jssidebar-generated-html/1332/4 "2022-10-14T19:39:39Z")

</div>

There was an alignment improvement on core side from @andraes_k : [https://gerrit.libreoffice.org/c/core/+/141380](https://gerrit.libreoffice.org/c/core/+/141380)

---

<div class="post-metadata">

### Author: ![vmiklos](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.collaboraonline.com/vmiklos/32/787_2.png) [@vmiklos](https://forum.collaboraonline.com/u/vmiklos)
#### Post date: [April 21, 2026, 12:36pm UTC](https://forum.collaboraonline.com/t/jssidebar-generated-html/1332/5 "2026-04-21T12:36:24Z")

</div>


